Archive for December, 2013

generic list in vb

December 18, 2013

here’s a good link for reference:
and I also used:

1) we have a generic list: Private Shared m_ListLDAP As List(Of PersonPermission)

2) the class
Public Class PersonPermission
Public netid As String
Public campus As String
Public usertype As String

Public Sub New(snetid As String, slocation As String, stype As String)
netid = snetid
campus = slocation
usertype = stype
End Sub

Public Sub New()
End Sub

End Class

3) we load the list from a datatable
4) then later in the code, we find an element in the list based on the user netid, and return some values. Frankly, I don’t understand the syntax. To me, it looks like LINQ, but I guess the Find function of the generic list is calling my little inline delegate function … or something like that.

' ******************************************************************************************************************
' purpose - search the list on netid, return campus and usertype
Public Shared Sub get_ldap_override_values(ByVal netid As String, ByRef campus As String, ByRef usertype As String)

If (IsNothing(m_ListLDAP)) Then load_user_list()
campus = ""
usertype = ""
Dim myLocatedObject As PersonPermission = m_ListLDAP.Find(Function(p) p.netid = netid)
If (Not IsNothing(myLocatedObject)) Then
campus = myLocatedObject.campus
usertype = myLocatedObject.usertype
End If
End Sub