If sub Class method has same signature as super class method, then sub class method hides the super class method. If you come from java background, it is quite different (To achieve run time polymorphism (or) method overriding, you need to use virtual keyword).
Following example is for the guys, who come from Java background.
Which method is called, when my sub class instance points to super class variable?
A a= new B();
a.print(); // Calls super class print method
If you are from Java, you definitely say, sub class method is called (Refer method overriding). But in C#, super class print method is called. To achieve run time polymorphism, you need to use the ‘virtual’ keyword. I will explain this in later post.
I am in A
Previous Next Home