Declaring and Using Global Arrays c#

前端 未结 8 2088
星月不相逢
星月不相逢 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:34

    this is a very bad idea.

    1. avoid global variables as much as possible. there are few instances where you need a public, mutable singleton.
    2. use an explicit object (POCO) instead of a multi-dimensional array. see below for an example
    3. instead create/save/load the objects from storage as needed.

      class Auction { public long Id {get; set;} public string ItemName {get; set;} ... }

提交回复
热议问题