.net problem?anybody solve it??

dexter

Member
Joined
Dec 18, 2008
Messages
8
Programming Experience
Beginner
It has to do with the same old story I've posted weeks ago..... and I'm so angry about VB. Net

Someone solve me this one, please:
----------------------------------------
VB.NET:
Public Class Thinger

  Private arrThings As ArrayList

  Public Sub New()
    Me.arrThings = New ArrayList()
  End Sub

  Public Sub AddThing(String thingId)
    Dim x As New Thing(thingId)
    Me.arrThings.Add(x)
  End Sub

  Public Function GetThings() As Thing()
    Return CType(Me.arrThings.ToArray(?#@!?), Thing())
  End Function

End Class
 
1. Why would you be angry at VB.NET when the documentation for the ArrayList.ToArray method contains a code example that specifically answers your question?
MSDN said:
VB.NET:
        ' Copies the elements of the ArrayList to a string array.
        Dim myArr As String() = CType(myAL.ToArray(GetType(String)), String())
2. You shouldn't use an ArrayList in .NET 2.0 or later anyway. If you use a generic List then you can call ToArray without having to specify a type or having to cast.
 
Back
Top