简体   繁体   English

方法声明中的C#new

[英]C# new in method declaration

public new int AdjustedBaseValue

这里的新内容是什么意思或做什么?

It means you are shadowing the int value. 这意味着你正在影响int值。 It is declared in a base class and you are re-declaring it in a derived class, effectively hiding the base class version. 它在基类中声明,并且您在派生类中重新声明它,有效地隐藏了基类版本。

See here for more information. 有关更多信息,请参见此处

In this case, new is a modifier that hides an inherited member from the base class. 在这种情况下, new是一个修饰符,它隐藏了基类中的继承成员。 See the documentation . 请参阅文档

Here is a good forum post with some examples between the differences of using new vs override 这是一篇很好的论坛帖子,其中介绍了使用new vs override的不同之处

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

New is to hiding the baseclass implementation. 新的是隐藏基类实现。 Stoping the polymorphism... 确定多态性......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM