Among Find, Single, First, which one is the fastest?

前端 未结 5 1846
庸人自扰
庸人自扰 2020-12-30 23:28

I want to minimize the time needed to retrieve a single unique element from a list. Which one is the fastest method among Find, Single and Fi

5条回答
  •  爱一瞬间的悲伤
    2020-12-31 00:05

    As an addition to the existing answers: List.Find is much faster than IEnumerable.First because the first one can operate on the List's internal Array. The latter one has to go through the IList interface.

提交回复
热议问题