How do I manage global data within a project?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I learned that C# doesn't allow global variables within a project. However,
I have a structure that I wish to store data within. The data is retrieved
from multiple forms within my project. How do I create a global data
structure within C# and properly store/retrieve data to it via multiple forms?
 
Steve,

You can always declare an instance of this structure/class to be static.
If the field/property is static (and public), then any type in the same app
domain can access that field.

Hope this helps.
 
Steve Teeples said:
I learned that C# doesn't allow global variables within a project.
However, I have a structure that I wish to store data within. The
data is retrieved from multiple forms within my project. How do I
create a global data structure within C# and properly store/retrieve
data to it via multiple forms?

Either use straight public static variables or a singleton pattern.

See http://www.pobox.com/~skeet/csharp/singleton.html
 
Back
Top