C# Storing string,int,string in an accessable variable

前端 未结 5 1824
故里飘歌
故里飘歌 2021-01-26 05:16

I need to save a class with list of countries in statics for caching.

the data is built with

string shortName //Primary Key - (IL or UK for example)
int         


        
5条回答
  •  迷失自我
    2021-01-26 05:45

    You should create a custom type:

    public class Country
    {
      public string ShortName {get; set;}
      public int ID {get; set;}
      public string LongName {get; set;}
    }
    

    and then store the countries in a Dictionary from which you'll be able to do:

    var UK = _countries["UK"];
    UK.ID...
    UK.LongName...
    

提交回复
热议问题