“new” keyword in property declaration in c#

前端 未结 5 1438
忘掉有多难
忘掉有多难 2020-12-01 15:26

I\'ve been given a .net project to maintain. I was just browsing through the code and I noticed this on a property declaration:

public new string navUrl
{
           


        
5条回答
  •  醉酒成梦
    2020-12-01 16:21

    It hides the navUrl property of the base class. See new Modifier. As mentioned in that MSDN entry, you can access the "hidden" property with fully qualified names: BaseClass.navUrl. Abuse of either can result in massive confusion and possible insanity (i.e. broken code).

提交回复
热议问题