C# Why does code compile fine when there is an ambiguous virtual method?

Posted by Jimbo on Stack Overflow See other posts from Stack Overflow or by Jimbo
Published on 2010-05-27T10:20:09Z Indexed on 2010/05/27 10:21 UTC
Read the original article Hit count: 161

Filed under:
|
|
|

I have a class (Class B) that inherits another class (Class A) that contains virtual methods.

Mistakenly, I omitted the override keyword when declaring a (supposed to be) overriding method in Class B.

Class A

public class ClassA{
    public virtual void TestMethod(){
    }
}

Class B

public class ClassB : ClassA{
    public void TestMethod(){
    }
}

The code compiled without a problem. Can anyone explain why?

© Stack Overflow or respective owner

Related posts about c#

Related posts about inheritance