c# - "Use the new keyword if hiding was intended"警告

标签 c# winforms

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

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

如果我双击它,它会出现:

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

谁能告诉我如何摆脱它?

最佳答案

你的类有一个基类,这个基类还有一个名为 Events 的属性(不是虚拟的或抽象的),它被你的类覆盖了。如果您打算覆盖它,请在 public 修饰符之后放置“new”关键字。例如

public new EventsDataTable Events
{
  ..
}

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

关于c# - "Use the new keyword if hiding was intended"警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19193821/

相关文章:

c# - RemoveAt 收集失败

C# 等效于 VB 6 DoEvents

c# - 需要从 .Net 2 升级到更新的版本?

c# - 在 c# 中的 tabControl 中显示第一个标签页的下一个标签页

.net - 如何创建异步控制包装器?

c# - 如何在 C# Winform 的文本框事件处理程序中禁用或捕获 "paste"或 "Control+V"事件?

c# - 如何使用 https 打开 RadWindow

c# - 如何将 Fitnesse 与 Autofac/IOC 集成?

c# - 需要一种更好的方法来遍历表单控件

C# 按钮可见性问题