6
Answers

About base in C#

Max Albish

Max Albish

10y
800
1
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)