任何人都可以教我如何在C#中按字母顺序将项目插入列表?
因此,每次我添加到列表中时,我都希望在列表中添加一个项目,理论上列表可能会变得非常大.
示例代码:
Public Class Person
{
public string Name { get; set; }
public string Age { get; set; }
}
Public Class Storage
{
private List<Person> people;
public Storage
{
people = new List<Person>();
}
public void addToList(person Person)
{
int insertIndex = movies.findindex(
delegate(Movie movie)
{
return //Stuck here, or Completely off Track.
}
people.insert(insertIndex, newPerson);
}
}
Run Code Online (Sandbox Code Playgroud)