I am trying to create a data structure CityPosition
, in which to have 3 variables: CityName
, PositionX
, PositionY
.
I tried creating a class:
Public Class CityPosition
Public Shared CityName As String
Public Shared LocX As Double
Public Shared LocY As Double
Public Sub New(ByVal name, ByVal x, ByVal y)
CityName = name
LocX = x
LocY = y
End Sub
End Class
As I have to collect lots (unknown number) of instances of that class, I created an ArrayList element:
Dim CityPositions As New ArrayList
Finally, I am trying to add an instance of the class to the ArrayList by this:
CityPositions.Add(New CityPosition(Positions(0), LocX, LocY))
- Please let me know if I am doing it right, because I am a VB.NET newbie.
- How to access the instance properties? I tried
CityPositions(0).CityName
but it seems not to work