Populating Structure Arrays

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If you define a structur
Private Structure Str
Dim X as Intege
Dim Y as Strin
End Structur

Is there a way to populate the structre when you define the array
Dim XX() as StrX = Str((1,'A'), (2,'B')

Thank

David
 
Well, you could something like this, adding a constructor with the required
parameters:

Private Structure StrX
Dim X As Integer
Dim Y As String

Sub New(ByVal xParam As Integer, ByVal yParam As String)
X = xParam
Y = yParam
End Sub
End Structure

and when intializing something like this:

Dim XX() As StrX = New StrX() {New StrX(1, "a"), New StrX(2, "b")}
 
Back
Top