Just playing with Generics in Visual Basic Whidbey

My simple class:

				Public Class Customer
    Dim m_CustomerName As String
    Dim m_CustomerID As Integer
    Public Property CustomerName() As String
            Return m_CustomerName
        End Get
        Set(ByVal Value As String)
            m_CustomerName = Value
        End Set
    End Property
    Public Property CustomerID() As Integer
            Return m_CustomerID
        End Get
        Set(ByVal Value As Integer)
            m_CustomerID = Value
        End Set
    End Property
End Class

Then creating a Generic List and working with it:

    Private Sub FillCustomers()
        Dim myCustomers _
            As New Generic.List(Of Customer)
        Dim C As Customer
        For i As Integer = 1 To 500
            C = New Customer
            C.CustomerID = i
            C.CustomerName = "Name " & i
        For Each cust As Customer In myCustomers
    End Sub

Now, isn’t that nice?

Author: Duncan Mackenzie

I'm the Developer Lead for the Channel 9 team, formerly worked on MSDN as a developer, content strategist and author.

Leave a Reply