Using VB in .NET2
Public Class GroupSID
Private _groupName As String
Private _sid As String
Public Property GroupName() As String
Get
Return _groupName
End Get
Set(ByVal value As String)
_groupName = value
End Set
End Property
Public Property SID() As String
Get
Return _sid
End Get
Set(ByVal value As String)
_sid = value
End Set
End Property
End Class
After the list is populated I want to find the item with the matching groupName (there will be only 1)
Something like (pseudo VB/C#)
'Dim result As GroupSID = ListOfGroupSID.Find(x => x.GroupName == groupName)
from: http://www.codeproject.com/Articles/388257/Csharp-Tips-Using-delegate-in-List-Find-predicate
' expression expected error on Function(p)
Dim result As GroupSID = ListOfGroupSID.Find(Function(p) p.GroupName = groupName)
Problem is VB8/.NET2 doesn't allow this..
Anonymous function (lambda) aren't available in VB8/.Net2 so you have to define your predicate as a separate method :
Function BelongsToSameGroup(ByVal group As GroupSID) As Boolean
Return group.GroupName = groupName ' need to be accessible
End Function
' usage
Dim result As GroupSID = ListOfGroupSID.Find(AddressOf BelongsToSameGroup)