开发者

How to convert datatable into generic type

How to convert DataTable having N rows into KeyValuePair<long,string>[] type having same N no of rows

I want to return KeyVal开发者_JAVA技巧uePair<long,string>[] kind of value from a function that will convert DataTable into above type.


return table.AsEnumerable()
    .Select(r => new KeyValuePair<long, string>(r.Field<long>("longFieldName"), r.Field<string>("stringFieldName")))
    .ToArray();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜