I am a bit confused about the virtual
/new
/override
thing. Here\'s an example:
class A
{
public virtual void mVVirt
Do you have warnings hidden? When I do what you've done, I get this warning:
'ProjectName.ClassName.B.mVVirtual()' hides inherited member 'ProjectName.ClassName.A.mVVirtual()'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.
If you used override
in class B, you wouldn't have this problem; both cases would give you "C::mVVirtual". Since you're not using override
in class B, there's an implicit new
in front of the method. This breaks the inheritance chain. Your code is calling a method on type A, and there are no inheriting classes that override that method due to the implicit new
. So it has to call class A's implementation.