“如果打算隐藏则使用new关键字”;警告 [英] "Use the new keyword if hiding was intended" warning

查看:157
本文介绍了“如果打算隐藏则使用new关键字”;警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在屏幕底部有一个警告:

I have a warning at the bottom of my screen:


警告1'WindowsFormsApplication2.EventControlDataSet.Events'隐藏
继承的成员
'System.ComponentModel.MarshalByValueComponent.Events'。如果要隐藏,请使用新的
关键字。 C:\Users\myComputer\Desktop\Event
Control\WindowsFormsApplication2\EventControlDataSet.Designer.cs 112 32 eventControl

Warning 1 'WindowsFormsApplication2.EventControlDataSet.Events' hides inherited member 'System.ComponentModel.MarshalByValueComponent.Events'. Use the new keyword if hiding was intended. C:\Users\myComputer\Desktop\Event Control\WindowsFormsApplication2\EventControlDataSet.Designer.cs 112 32 eventControl

如果我双击它,它将显示:

If i double click on it, it comes up with:

public EventsDataTable Events {
    get {
        return this.tableEvents;
    }

有人可以告诉我如何摆脱它吗?

Can anyone tell me how to get rid of this?

推荐答案

您的类有一个基类,并且该基类还具有一个称为Events的属性(不是虚拟的或抽象的),该属性被覆盖你的班。如果您打算覆盖它,则将 new关键字放在public修饰符之后。 EG

Your class has a base class, and this base class also has a property (which is not virtual or abstract) called Events which is being overridden by your class. If you intend to override it put the "new" keyword after the public modifier. E.G.

public new EventsDataTable Events
{
  ..
}

如果您不想覆盖它,请将属性名称更改为其他名称。

If you don't wish to override it change your properties' name to something else.

这篇关于“如果打算隐藏则使用new关键字”;警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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