【问题标题】:Get Nth item from SelectList从 SelectList 中获取第 N 项
【发布时间】:2011-08-24 15:49:00
【问题描述】:

我正在尝试对返回 SelectList 的函数进行单元测试。

如何从 SelectList 中检索项目以验证我的模型是否正确构建?

mySelectList.Items.First().DataValue

或其他。

【问题讨论】:

    标签: linq c#-4.0 ienumerable selectlist selectlistitem


    【解决方案1】:

    只需使用mySelectList.ElementAt(n) 即可获得第n 个SelectListItem。

    【讨论】:

      猜你喜欢
      • 2015-11-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-17
      • 1970-01-01
      • 2014-05-15
      • 2013-08-24
      • 2015-02-07
      • 1970-01-01
      相关资源
      最近更新 更多