开发者

Convert IEnumerable<Dictionary<int, string>> to List<Dictionary<int, string>>

开发者 https://www.devze.com 2023-03-29 02:40 出处:网络
var a = GetIEnumerableDictionary(); a is IEnumerable<Dictionary<int, string>>. How do I co开发者_StackOverflownvert a to List<Dictionary<int, string>> ?a.ToList() should do
var a = GetIEnumerableDictionary();

a is IEnumerable<Dictionary<int, string>>. How do I co开发者_StackOverflownvert a to List<Dictionary<int, string>> ?


a.ToList() should do the trick.

The ToList() extension method lives in the System.Linq namespace. If Linq is not available, the List<T> constructor takes an IEnumerable<T> as a parameter, as Jalal has already answered on this page.


You can use the List IEnumerable<T> constructor, so:

List<Dictionary<int, string>> myList = new List<Dictionary<int, string>>(a);
0

精彩评论

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

关注公众号