【问题标题】:Convert System.Collections.Generic.SortedList<string,T> into IEnumerable<T>将 System.Collections.Generic.SortedList<string,T> 转换为 IEnumerable<T>
【发布时间】:2012-01-19 07:58:09
【问题描述】:

什么是最有效的转换方式

System.Collections.Generic.SortedList<string,Contact>

变成一个

IEnumerable<Contact>

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

【问题讨论】:

    标签: c# generics collections ienumerable


    【解决方案1】:

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

    【讨论】:

    • +1 - 是的 - 仅适用于 Journeyman - 这将返回一个实现 IEnumerable 的 IList
    猜你喜欢
    • 2018-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-24
    • 2021-12-02
    • 2013-06-07
    • 1970-01-01
    相关资源
    最近更新 更多