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,
Loading
Mukesh KaranwalPosted Apr 9, 2010, 7:12 AM
Thanks a lot..:-)
Hirendra SisodiyaPosted Apr 9, 2010, 6:08 AM
Hello Mukesh
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 KaranwalPosted Apr 9, 2010, 5:31 AM
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 SisodiyaPosted Apr 9, 2010, 1:36 AM
why are you not making this as public, i think you should be declare this variable as public....
thanks