开发者

C# new in method declaration

public new int AdjustedBaseValue

What does the new here me开发者_Go百科an or do?


It means you are shadowing the int value. It is declared in a base class and you are re-declaring it in a derived class, effectively hiding the base class version.

See documentation here for more information.

Refer example here


In this case, new is a modifier that hides an inherited member from the base class. See the documentation.


Here is a good forum post with some examples between the differences of using new vs override

http://social.msdn.microsoft.com/Forums/en/Vsexpressvcs/thread/65e02299-300f-4b74-8f0a-679f490605f5


New is to hiding the baseclass implementation. Stoping the polymorphism...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜