Using LINQ to remove elements from a List

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

    LINQ has its origins in functional programming, which emphasises immutability of objects, so it doesn't provide a built-in way to update the original list in-place.

    Note on immutability (taken from another SO answer):

    Here is the definition of immutability from Wikipedia.

    In object-oriented and functional programming, an immutable object is an object whose state cannot be modified after it is created.

提交回复
热议问题