What is the Efficiency and Performance of LINQ and Lambda Expression in .Net?

后端 未结 6 1551
粉色の甜心
粉色の甜心 2020-11-27 12:46

I have used .Net 3.5 and VS 2008 for more than a month. Like most .Net developers, I have evolved from years experience in .Net 1.0 & 2.0 and VS 2005. Just recently, I d

6条回答
  •  臣服心动
    2020-11-27 13:31

    Technically the fastest way is to control all the minutia yourself. Here are some performance tests. Notice that the foreach keyword and the ForEach LINQ construct are identically far far slower than just using for and writing procedural code.

    However, the compiler can and will be improved and you can always profile your code and optimize any problematic areas. It is generally recommended to use the more expressive features that make code easier to read unless you really need the extra nanoseconds.

提交回复
热议问题