开发者

passing data from data set to a dictionary

Basically I have a data set with some data a data base table, I want to pass the data to a dictionary, what could be a good way yo accomplish my goal. Assuming that the dictionary have this structure

Dictionary<int,string>

I'开发者_StackOverflow中文版m looking for some method to bind the rows of the dataset with the key and value of the dictionary.


Your question is pretty vague, if your dataset implements IEnumerable or IQueryable you can use the ToDictionary extension method:

Dictionary<int, string> dict = data.ToDictionary(e => e.id, e => e.name);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜