dynamisches Array

Private Function GetMyArray() As SomeClass()
     Dim MyArray As New ArrayList
     Dim CurrentItem As SomeClass ' hat Eigenschaften ID, Name

     For i As Integer = 0 To MyData.Count - 1
          CurrentItem = New SomeClass
          With CurrentItem
               .ID = i
               .Name = "blah " & i.ToString
          End With

          MyArray.Add(CurrentItem)
     Next

     Return DirectCast(MyArray.ToArray(GetType(SomeClass)), SomeClass())
End Function

Schreibe einen Kommentar