The problem that I am having is that I declare a private string variable, and use it inside a method, supposely the value will be set inside this method. And on other method the value will be retrieve back and display. After tracing the code in debug mode, I saw the value change in method A, but when it comes to display, the value changes to null again.
//code below
private string display = "";
private Label label1 = new Label();
private void Method1()
{
display = "Hello!!"; //This has assigned to the string
//value successfully.
}
private void Method2()
{
Label1.Text = display; //I have traced this, and here it
//showed as NULL;
}
I don't understand why this is happening??
Isn't private string display supposed to be a global variable?
Can someone please explain this to me??
I am confused. . . .
Laic
//code below
private string display = "";
private Label label1 = new Label();
private void Method1()
{
display = "Hello!!"; //This has assigned to the string
//value successfully.
}
private void Method2()
{
Label1.Text = display; //I have traced this, and here it
//showed as NULL;
}
I don't understand why this is happening??
Isn't private string display supposed to be a global variable?
Can someone please explain this to me??
I am confused. . . .
Laic