将System.Collections.Generic.SortedList <string,T>转换为IEnumerable <T>

Jou*_*man 1 c# generics collections ienumerable

转换a的最有效方法是什么?

System.Collections.Generic.SortedList<string,Contact>
Run Code Online (Sandbox Code Playgroud)

进入

IEnumerable<Contact>
Run Code Online (Sandbox Code Playgroud)

IEnumerable的使用者是一个MVC视图,它希望按照它们存储在System.Collections.Generic.SortedList中的顺序显示这些项目.

Jef*_*hao 7

SortedList.ValuesSortedList.GetValueList(仅在非通用版本中)正是您所需要的.