gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 03:37:43 26 4
gpt4 key购买 nike

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

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com