Home > DeveloperSection > Forums > How to make a global list in c#
john rob

Total Post:108

Points:756
Posted on    December-27-2013 6:51 AM

 C# C# 
Ratings:


 1 Reply(s)
 1608  View(s)
Rate this:
I have three windows forms in my project, and I have an object class. How can I make a list of those objects that will be available for all three forms to use?


Alex Leblois
Alex Leblois

Total Post:67

Points:471
Posted on    December-27-2013 7:40 AM

Hi John,

You could create a class containing an instance of your object:

public class MyClass

{

    public static List<string> MyList {get; set}

}

Then you can access it from your form

MyClass.MyList = new List<string>();

Obviously string will be replaced with the name of your object.


Don't want to miss updates? Please click the below button!

Follow MindStick