I know it's not possible to create a global variable in C# but what I want is to declare a variable on form1, assign it a value and use this variable on form2.
How do I do that ???
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jul 29, 2012, 8:51 AM
class Form1 : Form
{
internal static MyInt;
public Form1()
{
InitializeComponent();
MyInt = 42;
}
// etc
}
// code to access this variable from Form2:
int i = Form1.MyInt;
Waqas AliPosted Jul 29, 2012, 6:43 AM
alok singhPosted Jul 29, 2012, 5:40 AM