Declaring and Using Global Arrays c#

前端 未结 8 2107
星月不相逢
星月不相逢 2020-12-30 12:02

I couldn\'t find any information pertaining to this question. I am trying to create a global array in C# so that I can input information into it at different points in my co

8条回答
  •  抹茶落季
    2020-12-30 12:25

    Well, aside from the fact that you likely have a structural problem if you're storing stuff globally.

    You can use a static property for this.

     public class MyVariables
     {
         private static string[] _MyStuff
         public static string[] MyStuff
         {
               return _MyStuff;
         }
     }
    

    Then access it like this:

    MyVariables.MyStuff[0]
    

提交回复
热议问题