There are several forms in the Windows Forms project. It is necessary that from each form you can refer to the array. For example, from one to fill it, to another to output, and so on. Where can I initialize this array so that it can be accessed from all forms? Ps array of type int.

    1 answer 1

    Well, for your problem this solution will go well:

    public static class Holder { static List<int> _array = new List<int>(); public static List<int> GetArray { get { return _array; } set { array_ = value; } } } 
    • And without classes it can be implemented? ) - ProgerStudent 3:49
    • @ProgerStudent, and why? Well, make an array in one of the code-behind public, and knock on it. only this somehow absolutely at all ... - Max Zhukov
    • absolutely noob question: what is the code-behind? - ProgerStudent
    • Form1.cs file, etc. - Max Zhukov
    • Well, I'm right in it trying to declare an array public int [] array; if I try to do this in the namespace, I get an error "a class is required, a delegate ..." and if I do it in public Form1 () {InitializeComponent (); } then, as I understand it, it will not be visible to other forms - ProgerStudent