开发者

How to convert datatable into generic type

开发者 https://www.devze.com 2023-01-11 18:06 出处:网络
How to convert DataTable having N rows into KeyValuePair<long,string>[] type having same N no of rows

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

精彩评论

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

关注公众号