我可以在C#中覆盖非抽象方法吗? [英] Can I Override Non-Abstract Method In C#?
本文介绍了我可以在C#中覆盖非抽象方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以覆盖c#中的非抽象方法吗?
can i override non-abstract method in c#?
推荐答案
是的,但你必须用虚拟 [ ^ ]关键字。
您还可以隐藏从基类继承的方法/成员使用新 [ ^ ]修饰符。您想要这样做的唯一原因是,当您从属于第三方库的类继承并且该方法未标记为虚拟时。
Yes, but you would have to mark it with the virtual[^] keyword.
You can also hide a method/member that is inherited from a base class by using the new[^] modifier. The only reason why you would want to do that though, is when you're inheriting from a class that is part of a third party library and the method is not marked as virtual.
是,或者你可以使用new隐藏它
http://msdn.microsoft.com/en-us/library/ebca9ah3.aspx [ ^ ]
Yes, or you can hide it usingnew
http://msdn.microsoft.com/en-us/library/ebca9ah3.aspx[^]
这篇关于我可以在C#中覆盖非抽象方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文