The variable is either undeclared or was never assigned warning

I have code like this:

This is base class:

public class BaseClass : UserControl
{
     protected ListView list;
     protected TreeView tree;

     public BaseClass()
     {
         //...
     }
     //...
}

Child 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";
    }
}

And warnings:

Warning 1 The variable 'tree' is either undeclared or was never assigned.
Warning 2 The variable 'list' is either undeclared or was never assigned.

What am I doing wrong ? This variable are declared in base class, and assigned in child class.

Answers


This question lacks an answer, so here goes...

Rebuild Solution then restart Visual Studio worked for me :-)

Thanks to SLaks for his comment above.

Also discussed at:

stackoverflow.com - The variable 'variable_name' is either undeclared or was never assigned.

social.msdn.microsoft.com - The variable 'control_name' is either undeclared or was never assigned.


Need Your Help

Processing Mandrill Inbound emails

node.js http meteor iron-router mandrill

I am having trouble processing inbound emails from mandrill with Meteorjs. I am a bit of a newbie when it comes to writing server side routes / API routes, so I hope I am not overlooking something

cakephp redis storage besides sessions

cakephp redis cakephp-2.0 cakephp-2.3

I am trying to use redis as my caching engine and I have so far was able to add the add redis in cakephp and it writes my sessions to my redis just fine. This is what I did in the core

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.