C# 过滤字典中的数据 并将过滤后的数据转成新的字典对象

                Dictionary<string, object> dic = new Dictionary<string, object>();
                dic.Add("DistrictID_1", "123");
                dic.Add("Dist_1", "456");
                dic.Add("DistD_1", "555");
                dic.Add("Dff_1", "666");
                dic.Add("DistrictID_2", "123");
                dic.Add("Dist_2", "456");
                dic.Add("DistD_2", "555");
                dic.Add("Dff_2", "666");

                var re = dic.Where(p => p.Key == "DistrictID_1").Select(p => p.Key);

                var formList = (from p in dic where p.Key.Contains("_1") select p);
                Dictionary<string, object> dic1 = formList.ToDictionary(k => k.Key, v => v.Val

 

你可能感兴趣的:(C# 过滤字典中的数据 并将过滤后的数据转成新的字典对象)