Why is List<>.OrderBy LINQ faster than IComparable+List<>.Sort in Debug mode?

前端 未结 4 2200
情歌与酒
情歌与酒 2021-02-19 11:30

I was interested in whether it would be faster to sort my classes using LINQ, or by implementing the IComparable interface and List.Sort. I was quite surprised when the LINQ cod

4条回答
  •  春和景丽
    2021-02-19 12:03

    This could it be the overhead of calling the method CompareTo which would be replaced with an inline when compile and run in release mode.

提交回复
热议问题