Using LINQ to remove elements from a List

前端 未结 14 2218
抹茶落季
抹茶落季 2020-11-22 11:09

Say that I have LINQ query such as:

var authors = from x in authorsList
              where x.firstname == \"Bob\"
              select x;

14条回答
  •  青春惊慌失措
    2020-11-22 11:33

    i think you just have to assign the items from Author list to a new list to take that effect.

    //assume oldAuthor is the old list
    Author newAuthorList = (select x from oldAuthor where x.firstname!="Bob" select x).ToList();
    oldAuthor = newAuthorList;
    newAuthorList = null;
    

提交回复
热议问题