可能重复:
how to find the index particular items in the list using linq?从阵列中创建一个选择列表
我想从一个字符串数组创建IEnumerable<SelectListItem>
。
string[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
model.month = months
.Select(r => new SelectListItem{Text = r, Value = ???});
是否有此查询中访问其索引的方法吗?
http://msdn.microsoft.com/en-us/library/bb534869.aspx –