Max Albish

Max Albish

  • 1.6k
  • 142
  • 17.8k

About base in C#

Oct 1 2014 7:09 PM
namespace contest { class Program { static void Main(string[] args) {             B b = new B(); } } class A { public A() {             k(); } private void k() { Console.WriteLine(base.GetType().Name); } } class B : A { } }

Can someone tell me why it outputs "B" instead of "Object", doesn't base.GetType() get A's parent object therefore the root Object?

Thanks a lot


Answers (6)