小编Jay*_*ave的帖子

按字母顺序插入列表C#

任何人都可以教我如何在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)

.net c#

14
推荐指数
3
解决办法
8334
查看次数

标签 统计

.net ×1

c# ×1