G
Guest
NOTE: This is a COMMENT...not a QUESTION:
For the newbies, I've been messing around with strongly typed ArrayLists so
I don't have to type so many "DirectCast". The following works great where
"myClass" is the classs that each ArrayList Element will contain:
dim myarraylist as typedArrayList = new typedArrayList
Public Class typedArrayList
Inherits ArrayList
Default Public Shadows Property Item(ByVal Index As Integer) As myClass
Get
Return DirectCast(MyBase.Item(Index), myClass)
End Get
Set(ByVal Value As myclass)
MyBase.Item(Index) = Value
End Set
End Property
End Class
You can then reference any property in myclass in your code instead of using
direct cast to cast the arraylist element to myClass:
myPropertyValue = myarraylist(0).myProperty
For the newbies, I've been messing around with strongly typed ArrayLists so
I don't have to type so many "DirectCast". The following works great where
"myClass" is the classs that each ArrayList Element will contain:
dim myarraylist as typedArrayList = new typedArrayList
Public Class typedArrayList
Inherits ArrayList
Default Public Shadows Property Item(ByVal Index As Integer) As myClass
Get
Return DirectCast(MyBase.Item(Index), myClass)
End Get
Set(ByVal Value As myclass)
MyBase.Item(Index) = Value
End Set
End Property
End Class
You can then reference any property in myclass in your code instead of using
direct cast to cast the arraylist element to myClass:
myPropertyValue = myarraylist(0).myProperty