HOW TO MAKE A GLOBAL LIST IN C#

john rob

Total Post:108

Points:756
Posted by  john rob
C# 
C#
 2433  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. Alex Leblois

    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!