开发者

Retrieving Dictionary from Datatable

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜