Compare two list elements with LINQ

后端 未结 5 1563
一生所求
一生所求 2021-01-13 07:42

I\'m trying to find a LINQ expression to compare two list elements.

What i want to do is:

List _int = new List { 1, 2, 3, 3, 4,         


        
5条回答
  •  逝去的感伤
    2021-01-13 08:13

    If you really want to do it with a lambda expression, add a bound check (that either always returns the last element or never, your choice).

    An iterative approach would be more readable though, IMO.

提交回复
热议问题