How do I form a good predicate delegate to Find() something in my List?

前端 未结 6 1542
囚心锁ツ
囚心锁ツ 2020-12-23 12:37

After looking on MSDN, it\'s still unclear to me how I should form a proper predicate to use the Find() method in List using a member variable of T (where T is a class)

6条回答
  •  忘掉有多难
    2020-12-23 12:43

    Since you can't use lambda you can just replace it with an anonymous delegate.

    myCar = carList.Find(delegate(Car car) { return car.Year == i; });
    

提交回复
热议问题