简体   繁体   中英

C# new in method declaration

public new int AdjustedBaseValue

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

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 here for more information.

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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