thmasker
thmasker

Reputation: 638

VB.NET Two-dimensional Collection?

I have a simple doubt but I can't find any information related to this. Is it possible to work with two-dimensional Collections in Visual Basic, or I just have to work with arrays?

In any case, how could I implement either in an array either in a collection, each dimension with a different Type Object?

Upvotes: 0

Views: 1150

Answers (1)

PavlinII
PavlinII

Reputation: 1083

You can use list of lists for dynamic lenght of 2nd dimension

Dim Lst As New List(Of List(Of String))

or two dimensional array

Dim Lst()() As String
Dim FixedLst(9)() As String

but in either case the final stored object type is still the same.

Do not forget to initialize the list/array object in 2nd dimension to avoid NullReferenceException.

Upvotes: 1

Related Questions