开发者

Retrieving Dictionary from Datatable

开发者 https://www.devze.com 2022-12-30 19:45 出处:网络
Have this dictionay retrieving values from DataTable: Dictionary开发者_JAVA技巧<string,string> meta= ds.Tables[1].Select(\"key<>\'format\'\").AsEnumerable().ToDictionary(k=>k.Field<

Have this dictionay retrieving values from DataTable:

Dictionary开发者_JAVA技巧<string,string> meta= ds.Tables[1].Select("key<>'format'").AsEnumerable().ToDictionary(k=>k.Field<string>(0),v=>v.Field<string>(1));

How would I apply StringComparer.OrdinalIgnoreCase as Mehrdad Afshari suggested ?


You can wrap it in another constructor:

var meta = new Dictionary<string,string>(ds.Tables[1]
                                           .Select("key<>'format'")
                                           .AsEnumerable()
                                           .ToDictionary(k=>k.Field<string>(0),
                                                         v=>v.Field<string>(1)),
                                         StringComparer.OrdinalIgnoreCase);
0

精彩评论

暂无评论...
验证码 换一张
取 消