Andy's blog

If you always do what you've always done, you'll always get what you've always got.

0%

2020-12-06-泛型別簡介2

繼續來介紹泛型別方法FindEnumerable.Where 方法


參考資料:
C# Linq where的用法


Where 方法

1
2
3
List<Test> list = new List<Test>();
list = list.where( a => a.test.Contains(Name)).ToList();

Find 方法

會返回整個List中的第一個匹配元素, 找不到傳回 null

1
2
3
List<Test> list = new List<Test>();
list = list.Find( a => a.test.Contains(Name)).ToList();