Do LINQ queries have a lot of overhead?

后端 未结 6 1880
梦毁少年i
梦毁少年i 2020-12-08 20:29

Are simple LINQ queries on an IEnumerable lightweight or heavyweight? How do they compare to writing for or foreach loops by

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 21:15

    Here is my general rule for LINQ

    Use LINQ when the solution is more expressive. Only switch to a less expressive but faster solution when a profiler has proved that the LINQ query is a source of problem.

提交回复
热议问题