Hi Daniel,
Thank you for posting in the community!
Based on my understanding, you want to know the difference between *use* or
*not use* base keyword to invoke method in C#.
=========================================================
Actually, if you explicit use base keyword, it means that you want to
invoke the BASE class's method. While "not use" the base keyword, you just
invoke your class's method, which may inherited from your BASE class.
So, the difference may expose using polymorphism, below is the sample code:
class A
{
public virtual void F() { Console.WriteLine("A.F"); }
}
class B: A
{
static void Main()
{
B b=new C();
b.test();
}
public void test()
{
base.F();
F();
}
public override void F() { Console.WriteLine("B.F"); }
}
class C: B
{
public override void F() { Console.WriteLine("C.F"); }
}
The output will generate:
A.F
C.F
So I think you have seen the difference, *not use* base keyword will lead
to the polymorphism, while *use* it will lead to explicit invoke base class
method.
=======================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.