
[英]Can DebuggerStepThrough be inherited into the automatically generated IEnumerable implementation?
[英]Inherited members automatically hidden by winforms generated code
我有两个链接到父类的子类,它们都是winform类。 问题出在所有类中的自动生成的代码上,这些代码具有以下公共签名:
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
//member inherited and hides parent's, however both derived and parent method are in designer sections (don't edit).
private new void InitializeComponent()
{
//auto-generated logic
}
根据编译器警告,我要消除:
Warning: 'Project.Windows.Forms.FirstChildClass.InitializeComponent()' hides inherited member 'Project.ParentClass.InitializeComponent()'. Use the new keyword if hiding was intended.
我需要子逻辑来隐藏父逻辑,并在上面的代码中通过添加new关键字实现了这一目的。 我只担心这可能会对Winforms产生不利影响。 由于自动生成的注释状态,不应对其进行编辑。
除非父成员被标记为virtual
否则您不能覆盖它们。 如果隐藏父成员,则从子类中调用该方法时,将使用该子方法。 父方法仅在父方法调用时才被调用。
如果您可以更具体地确定您要“覆盖”父类中的哪种行为,则可以使用另一种方法来解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.