"新"关键字属性声明在C# [英] "new" keyword in property declaration in c#

查看:179
本文介绍了"新"关键字属性声明在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经被赋予了.NET项目来维持。我只是翻阅了code,我注意到这对财产申报:

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
{
  get 
  {
    return ...;
  }
  set
  {
    ...
  }
}

我想知道是什么了修改做房地产?

推荐答案

它隐藏了基类的navUrl财产。请参见新修改。正如在MSDN进入,您可以访问隐藏属性,与完全合格的名称: BaseClass.navUrl 。或者滥用会导致大规模的混乱和可能的精神错乱(即破code)。

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

这篇关于"新"关键字属性声明在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆