LINQ查询索引
List<Person> People = new List<Person>
{
new Person { ID = 33, Name = "lyf"},
new Person { ID = 22, Name = "azw"}
};
var query = People.Select((person, index) => new { index, person.Name }).OrderBy(itm =>itm.Name);
foreach (var item in query)
{
Response.Write(item.index.ToString() + " " + item.Name + "<br/>");
}
public class Person
{
public int ID { get; set; }
public string Name { get; set; }
}
乌龟才背着房子过一辈子