How to make a global list in c#

Total Post:108

Points:756
C# 
C#
 3212  View(s)
Ratings:
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?
  1. Post:67

    Points:471
    Re: How to make a global list in c#

    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.

      Modified On Apr-04-2018 01:13:35 AM

Answer