这是基类:
public class BaseClass : UserControl
{
protected ListView list;
protected TreeView tree;
public BaseClass()
{
//...
}
//...
}
儿童班:
public partial class MyClass : BaseClass
{
public MyClass()
{
InitializeComponent();
this.BackColor = VisualStyleInformation.TextControlBorder;
this.Padding = new Padding(1);
}
//...
}
partial class MyClass
{
//...
private void InitializeComponent()
{
this.tree = new System.Windows.Forms.TreeView();
this.list = new System.Windows.Forms.ListView();
//...
this.tree.Location = new System.Drawing.Point(0, 23);
this.tree.Name = "blablabla";
}
}
编译这些类给了我这些警告:
Warning 1 The variable 'tree' is either undeclared or was never assigned.
Warning 2 The variable 'list' is either undeclared or was never assigned.
我究竟做错了什么?这些变量在基类中声明并在子类中分配。
这个问题缺少一个answer,所以这里...
重建解决方案然后重新启动 Visual Studio为我工作:-)
谢谢SLaks https://stackoverflow.com/users/34397/slaks对于他上面的评论。
还讨论过:
stackoverflow.com - 变量“variable_name”未声明或从未分配。 https://stackoverflow.com/questions/8521600/the-variable-variable-name-is-either-undeclared-or-was-never-assigned
Social.msdn.microsoft.com - 变量“control_name”未声明或从未分配。 http://social.msdn.microsoft.com/Forums/windows/en-US/4718ac1f-7443-423c-81d2-25059fec444d/the-variable-controlname-is-either-undeclared-or-was-never-assigned#0ececae7-fc50-4257-b80b-aecce43fb9ab
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)