Using LINQ to remove elements from a List

前端 未结 14 1906
抹茶落季
抹茶落季 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:43

    It'd be better to use List.RemoveAll to accomplish this.

    authorsList.RemoveAll((x) => x.firstname == "Bob");
    

提交回复
热议问题