简体   繁体   中英

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

var a = GetIEnumerableDictionary();

a is IEnumerable<Dictionary<int, string>> . How do I convert 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.

您可以使用List IEnumerable<T>构造函数,因此:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM