C# list to dictionary

示例:

新建一个类:

    public class Lang
    {
        public string En;
        public string Ch;
    }

实例化并转为字典:

  List<Lang> langs = new List<Lang>();
            langs.Add(new Lang() { Ch = "书籍", En = "Book" });
            langs.Add(new Lang() { Ch = "电影", En = "Film" });
            var dict = langs.ToDictionary(x => x.Ch, x => x.En);

            var value = dict["书籍"];

 

C# list to dictionary

上一篇:Git使用代理


下一篇:swagger 集成后发布到服务器报错[Could not find file 'D:\\home\\site\\wwwroot\\bin\\WebAPI.XML]