VB2005 固有の回答には、値を保持するクラスを作成してから、配列リストにクラスのインスタンスを設定することが含まれます。
クラス:
Public Class LookupList
Private m_Value As Integer
Private m_sDisplay As String
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal wValue As Integer, ByVal sDisplay As String)
Me.New()
Me.Value = wValue
Me.Display = sDisplay
End Sub
Public Property Value() As Integer
Get
Return m_Value
End Get
Set(ByVal value As Integer)
m_Value = value
End Set
End Property
Public Property Display() As String
Get
Return m_sDisplay
End Get
Set(ByVal value As String)
m_sDisplay = value
End Set
End Property
End Class
そして方法:
Public Shared Function GetGenders() As ArrayList
Dim oList As New ArrayList
oList.AddRange(New LookupList() {New LookupList(1, "ap"), New LookupList(2, "up")})
Return oList
End Function
元の C# コードに少し近い解決策は、クラスのコレクション クラスを作成することです。
Public Class LookupListCollection
Inherits System.Collections.Generic.List(Of LookupList)
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal ParamArray aItems As LookupList())
Me.New()
If aItems IsNot Nothing Then
Me.AddRange(aItems)
End If
End Sub
End Class
これは次のように呼び出すことができます。
Public Shared Function GetGenders() As LookupListCollection
Return New LookupListCollection(New LookupList(1, "ap"), New LookupList(2, "up"))
End Function