【发布时间】:2011-03-30 21:30:53
【问题描述】:
我需要重写 Tabcontrol GetTabRect。
protected override Rectangle GetTabRect(int index)
{...}
我收到此错误
错误 1“TabControl.GetTabRect(int)”: 无法更改访问修饰符 覆盖“公共”继承成员 'System.Windows.Forms.TabControl.GetTabRect(int)'
Error2'TabControl.GetTabRect(int)': 不能覆盖继承的成员 'System.Windows.Forms.TabControl.GetTabRect(int)' 因为它没有标记为虚拟, 抽象或覆盖
我该怎么做?
编辑
如果我使用公共:
TabControl.GetTabRect(int)': cannot override inherited member 'System.Windows.Forms.TabControl.GetTabRect(int)' because it is not marked virtual, abstract, or override
【问题讨论】:
-
该方法未标记为
virtual,因此您无法覆盖它(无论访问修饰符如何) -
@Ste:它不应该被覆盖
-
他不能使用public new Rectangle GetTabRect(int index)吗?
-
@Roflcoptr:这将隐藏基类方法,但不会覆盖它 - 这意味着如果您使用键入的引用访问他的类基类,基类方法仍然会执行。
标签: c# overriding