Hey All,
How can I take my private variable in the method and make it Public for another method to get a hold of it?
I have a class, Class1.cs. i have a method there which has a variable, now i want to use the value of this variable on a seperate form'Button_Click event!
How to go about this??
Thanks,
How to make a Private Variable Public??
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Hirendra SisodiyaRank #256 · 9.8K pointsPosted Apr 8, 2010, 9:36 PM EDT
thanks
Mukesh Karanwal8 pointsPosted Apr 9, 2010, 1:31 AM EDT
My application is such that i need to fetch a variables values which is defined and has some value inside a function.
and i need this value on some other form.
thanks
Hirendra SisodiyaRank #256 · 9.8K pointsPosted Apr 9, 2010, 2:08 AM EDT
apply this code on form1:
private void button1_Click(object sender, EventArgs e)
{
Class1 myCLS = new Class1();
//You need to call function my()
myCLS.my();
MessageBox.Show(myCLS.mySTR.ToString());
}
thanks
Please mark as answere if it helps
Mukesh Karanwal8 pointsPosted Apr 9, 2010, 3:12 AM EDT
Thanks a lot..:-)