变量未声明或从未分配警告
我有这样的代码:
这是基类:
public class BaseClass : UserControl { protected ListView list; protected TreeView tree; public BaseClass() { //... } //... }
儿童class
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上面的评论。
还讨论了:
stackoverflow.com – 变量’variable_name’未声明或从未分配过。
social.msdn.microsoft.com – 变量’control_name’未声明或从未分配过。
上述就是C#学习教程:变量未声明或从未分配警告分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/956924.html