C
cr113
I'm switching over from VB and I have a question.
Suppose I had a VB project with 2 forms and one variable. Call them
Form1,Form2 and strUsername. Suppose I want to initialize strUsername
to "jones" and use this value in Form1 and Form2 at any time.
In VB I would create a module with the following code:
Module test
Public strUsername As String
End Module
In my Form1_Load event I would have something like this:
Private Sub Form1_Load
strUsername = "jones"
End Sub
So my question is what would be the best way to do this in C#? I
realize there are no globals so the only thing I can think of doing is
to add a property to Form1 and Form2 called strUsername and set it each
time I activate either Form1 or Form2.
Suppose I had a VB project with 2 forms and one variable. Call them
Form1,Form2 and strUsername. Suppose I want to initialize strUsername
to "jones" and use this value in Form1 and Form2 at any time.
In VB I would create a module with the following code:
Module test
Public strUsername As String
End Module
In my Form1_Load event I would have something like this:
Private Sub Form1_Load
strUsername = "jones"
End Sub
So my question is what would be the best way to do this in C#? I
realize there are no globals so the only thing I can think of doing is
to add a property to Form1 and Form2 called strUsername and set it each
time I activate either Form1 or Form2.