Hi all,
Please help me solving following query:
How to add global variable in C# window base application. This variable must be accessible to all forms.
What I exactly want is:
I have a variable "UserName" and "UserType". When user click "Submit" button on Login form, user name get stored in variable "UserName" and user type get stored in variable "UserType". After click "Submit" button Login form get closed and "Project" form get open.
On "Project" form there are label "User Name" and "User Type". When "Project" form get open, the value of "UserName" and "UserType" variable should be get displayed in front of these labels.
I hope you understand my question.
Thanks and regards,
Swapnil.
How to define global variable in C#
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Dale15 reputationPosted Jul 13, 2006, 4:25 AM EDT
but i believe you dont want to create a global variable.
you want to define a method in the same class as your original form that returns The username and one that returns the usertype.
implement them somewhere between the constructor and destructor. Then call it from the second form with a reference to the original class and method.
This is something i am going to try in the near future so im not sure on all of the specifics. like i said i am new to this, but good luck and let me know if it helps, as i will be trying to do the same thing soon.
Dipen LamaRank #3,323 · 432 reputationPosted Jul 13, 2006, 4:31 AM EDT
Let me know if this solve your problem.