<p>Is it possible to search for an object by one of its properties in a Generic List?</p>

<pre><code>Public Class Customer

    Private _id As Integer

    Private _name As String

    Public Property ID() As Integer
        Get
            Return _id
        End Get
        Set
            _id = value
        End Set
    End Property

    Public Property Name() As String
        Get
            Return _name
        End Get
        Set
            _name = value
        End Set
    End Property

    Public Sub New(id As Integer, name As String)
        _id = id
        _name = name
    End Sub

End Class
</code></pre>

<p>Then loading and searching</p>

<pre><code>Dim list as new list(Of Customer)

list.Add(New Customer(1,"A")

list.Add(New Customer(2,"B")
</code></pre>

<p>How can I return customer object with id =1? Does this have to do with the "Predicate" in Generics?</p>

<p>Note: I am doing this in VB.NET.</p>

If you are using .NET 3.5 this can be done with
LINQ to Objects
:
How to: Query an ArrayList with LINQ
If not, in .NET 2.0 you can use the
```
Find
```
method of the list
.
The idea is that you will need to provide an method that return true if a property of your object satisfies a certain condition.