LINQ equivalent of List.Find()?

前端 未结 3 779
情书的邮戳
情书的邮戳 2021-02-03 12:51

I\'m looking at some code that takes an IEnumerable and converts it to a List so it can use List.Find(predicate):

var myEnumerable = .         


        
3条回答
  •  迷失自我
    2021-02-03 13:37

    The LINQ equivelent would be to use FirstOrDefault:

    var match = myEnumerable.FirstOrDefault(value => value.Aaa == aaa && value.Bbb == bbb);
    

提交回复
热议问题