[英]The variable is either undeclared or was never assigned warning
我有这样的代码:
这是基类:
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.
我究竟做错了什么 ? 该变量在基类中声明,并在子类中分配。
这个问题缺乏答案 ,所以这里......
Rebuild Solution然后重启Visual Studio为我工作:-)
感谢SLaks上面的评论。
还讨论了:
我和设计者都遇到过这个问题,每次的主要原因都是我的解决方案是为 x64 输出设置的。 目前,设计器无法处理 x64 解决方案集中的控件,因此您需要将其更改为 Any CPU,进行编辑,然后将其更改回 x64 以进行运行/调试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.