Order By vs Sort for creating ordered collection

前端 未结 1 1432
误落风尘
误落风尘 2020-12-31 18:51

I have been through this article C# Sort and OrderBy comparison

But the answer accepted in this question is obscure to me.

I can\'t decide when I sh

相关标签:
1条回答
  • 2020-12-31 19:15
    • You use Sort when you want to sort the original list. It performs an in-place sort.
    • You use OrderBy when you don't want to change the original list as it returns an IOrderedEnumerable<T> that leaves the original list untouched. Or when you don't have a list but some other enumerable.
    0 讨论(0)
提交回复
热议问题