Searching a list

InertiaM

Well-known member
Joined
Nov 3, 2007
Messages
663
Location
Kent, UK
Programming Experience
10+
VB.NET:
Public allVerticalHoles As List(Of VerticalHole)

<Serializable()>Public Class VerticalHole
    Private _ID As Int32 = 0
    Private _X As Single = 0
    Private _Y As Single = 0
    Private _strX as string = ""
    Private _strY as string = ""
    Private _Diameter As Single = 0
    Private _Depth As Single = 0
    Private _bMirrored As Boolean = False

    Public Property ID() As Int32
    '..
    End Property
    Public ReadOnly Property X() As Single
    '..
    End Property
    Public ReadOnly Property Y() As Single
    '..
    End Property
    Public Property strX() As String
    '..
    End Property
    Public Property strY() As String
    '..
    End Property
    Public ReadOnly Property Diameter() As Single
    '..
    End Property
    Public ReadOnly Property Depth() As Single
    '..
    End Property
    Public Property bMirrored() As Boolean
    '..
    End Property
End Class

How do I search for an item in the "allVerticalHoles" list by the X value as well as the Y value, or say the X value as well as the diameter ?
 
Last edited:
The List class has no specific functionality for this. You'll just have to loop through the items in the List and test each item. You could also define your own collection class, inheriting Collection(Of VerticalHole), and add your own methods to do the job. You'd still have to write the code to loop and test but it would then be encapsulated within the collection.
 
Many thanks - gave me the direction I needed :)
 
Back
Top