hi i want to share a variable between 2 form. 2 forms is in the one project. In fact,i want a global variable in the project how can i do it?
Language: c# .net
Thanks
hi i want to share a variable between 2 form. 2 forms is in the one project. In fact,i want a global variable in the project how can i do it?
Language: c# .net
Thanks
You can create a
static class
withstatic properties
inside that. That will do it.Create a public static property/method/variable.
Create a static class with static field/property like following:
use it in multiple forms like following:
The most straight forward way is to pass the variable to the forms.
It's hard to get into too much detail without knowing what your program does and how the forms are loaded, but I'd have the forms accept an argument in the constructor or something. If the argument is a reference type, both forms would reference the same data.