List<DB.Member> listOfMember = new List<DB.Member>()
{ new DB.Member(15), new DB.Member(20), new DB.Member(25), new DB.Member(30) };
// Exists: 單純看有無符合條件的資料
bool IsMemberExists = listOfMember.Exists(x => x.Email == "darren@acaciaco.com");
// FindIndex: 找出第一個符合條件的 index,找不到傳回 -1
int index = listOfMember.FindIndex(x => x.Email == "darren@acaciaco.com");
// Find: return 第一個符合條件的object, 找不到傳回 null
DB.Member objMember = listOfMember.Find(x => x.Email.Contains("acaciaco.com"));
// FindAll: return 所有符合條件的objects
List<DB.Member> listOfMember2 = listOfMember.FindAll(x => x.Email.Contains("acaciaco.com"));
VB
Dim listOfMember As New List(Of DB.Member)() From { _
New DB.Member(15), New DB.Member(20), New DB.Member(25), New DB.Member(30) }
' Exists: 單純看有無符合條件的資料
Dim IsMemberExists As Boolean = listOfMember.Exists(Function(x) x.Email = "darren@acaciaco.com")
' FindIndex: 找出第一個符合條件的 index,找不到傳回 -1
Dim index As Integer = listOfMember.FindIndex(Function(x) x.Email = "darren@acaciaco.com")
' Find: return 第一個符合條件的object, 找不到傳回 Nothing
Dim objMember As DB.Member = listOfMember.Find(Function(x) x.Email.Contains("acaciaco.com"))
' FindAll: return 所有符合條件的objects
Dim listOfMember2 As List(Of DB.Member) = listOfMember.FindAll(Function(x) x.Email.Contains("acaciaco.com"))