Why does this polymorphic C# code print what it does?

后端 未结 5 1079
逝去的感伤
逝去的感伤 2020-11-30 18:00

I was recently given the following piece of code as a sort-of puzzle to help understand Polymorphism and Inheritance in OOP - C#.

//         


        
5条回答
  •  悲哀的现实
    2020-11-30 18:34

    Actually, I think it should display C, because new operator just hides all ancestor methods with the same name. So, with methods of A and B hidden, only C remains visible.

    http://msdn.microsoft.com/en-us/library/51y09td4%28VS.71%29.aspx#vclrfnew_newmodifier

提交回复
热议问题