Hi all,
I wondered if anyone could help me with the best way to extract data from a custom class I created which inherits the use of ArrayList.
I have a users class as follows:
And a user Collections class as follows:
And I initialise via a my winform on load:
All the above works fine, but I want to extract the user details via something like:
Which doesn't work.
Does anyone have any ideas or tips?
I wondered if anyone could help me with the best way to extract data from a custom class I created which inherits the use of ArrayList.
I have a users class as follows:
VB.NET:
Public Class aUser
Public Sub New()
End Sub
Public Sub New(ByVal aName, ByVal aGen)
cName = aName
cGen = aGen
End Sub
Public Property Name() As String
Get
Name = cName
End Get
Set(ByVal value As String)
cName = value
End Set
End Property
Public Property Gen() As String
Get
Gen= cGen
End Get
Set(ByVal value As String)
cGen= value
End Set
End Property
End Class
And a user Collections class as follows:
VB.NET:
Imports System
Imports System.Collections
Public Class users_Col
Inherits ArrayList
Public Sub New()
End Sub
End Class
And I initialise via a my winform on load:
VB.NET:
'Form Load...
Dim objUsers as New users_Col
users_Col.Add(New aUser("Joe", "Male"))
users_Col.Add(New aUser("Mary", "Female"))
All the above works fine, but I want to extract the user details via something like:
VB.NET:
Dim userOne as string = users_Col(0).Name & " " & users_Col(0).Age
Dim userTwo as string = users_Col(1).Name & " " & users_Col(1).Age
Which doesn't work.
Does anyone have any ideas or tips?