Working with List(Of IdName)

Build 1501 on 14/Nov/2017  This topic last edited on: 25/Aug/2014, at 11:44

In a code such as this, that returns a List(Of IdName):

Dim login As Common.ILogin = Editorial.EditorialLogin.GetLogin()

Dim sc As SearchConditions = New SearchConditions(Schema.Class.copyrightObj.ObjectTypeName)

Dim list As List(Of IdName) = login.ListObjs(sc, False)

you can do following things:

Exit if list is empty:

If list.Count = 0 Then Exit Sub

Iterate entire list (reading only id and name):

For Each item As IdName In list

  Dim objid = item.Id

  Dim objName = item.Name

Next

Return true if the item is found by name:

' returns true if a format with name strFormatName exists for the element type strTypeName

Dim catList = New List(Of Integer)

Dim aFormats As List(Of IdName) = Ted.TxtFormatList(0, typographyId, Fred.GetTypeIdFromName(strTypeName), catList, 0)

If Not aFormats Is Nothing Then

  For Each item As IdName In aFormats

    If LCase(item.Name) = LCase(strFormatName) Then Return True

  Next

End If