2 dimensional array ?
-
Hi I need to use a 2 dimensional array that stores a filed of type string in the first column and a field of type integer in the second. I tried using system.array but there is cast type problems. What can i use? mr oizo
You can't combine those two in the same array, though you can create you're own class or structure to hold these.
Public Class MyDataItem
Private _someString As String
Private _someNumber As IntegerPublic Sub New(ByVal name As String, ByVal number As Integer) \_someString = name \_someNumber = number End Sub Public Property SomeString As String Get Return \_someString End Get Set(ByVal value As String) \_someString = value End Set End Property
...
End ClassAnd then you just create an array or collection of these little objects. I prefer to use a Generic List(Of T).
Dim myList As New List(Of MyDataItem) myList.Add(New MyDataItem("Something", n))
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
You can't combine those two in the same array, though you can create you're own class or structure to hold these.
Public Class MyDataItem
Private _someString As String
Private _someNumber As IntegerPublic Sub New(ByVal name As String, ByVal number As Integer) \_someString = name \_someNumber = number End Sub Public Property SomeString As String Get Return \_someString End Get Set(ByVal value As String) \_someString = value End Set End Property
...
End ClassAnd then you just create an array or collection of these little objects. I prefer to use a Generic List(Of T).
Dim myList As New List(Of MyDataItem) myList.Add(New MyDataItem("Something", n))
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007