help with multi-dimensional arraylist

I'm working on a vb.net project (2008) I have and I'm trying to figure
out how I can create a multi-dimensional array, arraylist, dictionary,
etc, whatever will allow me to do what I want to do.  I have data like
the following:

Blue, Green,
Black, Orange
Yellow, Red

Essentially value/pair stuff.  I already have it in a dictionary, but
it doesn't look like a dictionary has an index value for each of the
keys.  I want to be able to reference any of these "rows" by their
index value and the position of the item in the row (or column). So as
an example, I might want to know what the 2nd index row is and the
value of the 1 index inside that row (or the column).  That would be
"Red".  Is there a way of doing this in vb.net?  Not looking for code,
just the right type of object/function to us.  Thanks.

Steve
0
Awrightus
1/28/2010 10:04:08 PM
dotnet.languages.vb 830 articles. 0 followers. Follow

9 Replies
948 Views

Similar Articles

[PageSpeed] 31

On 2010-01-28, Awrightus <awrightus@gmail.com> wrote:
> I'm working on a vb.net project (2008) I have and I'm trying to figure
> out how I can create a multi-dimensional array, arraylist, dictionary,
> etc, whatever will allow me to do what I want to do.  I have data like
> the following:
>
> Blue, Green,
> Black, Orange
> Yellow, Red
>
> Essentially value/pair stuff.  I already have it in a dictionary, but
> it doesn't look like a dictionary has an index value for each of the
> keys.  I want to be able to reference any of these "rows" by their
> index value and the position of the item in the row (or column). So as
> an example, I might want to know what the 2nd index row is and the
> value of the 1 index inside that row (or the column).  That would be
> "Red".  Is there a way of doing this in vb.net?  Not looking for code,
> just the right type of object/function to us.  Thanks.
>
> Steve

How much data is typically going to be in this collection?

-- 
Tom Shelton
0
Tom
1/28/2010 10:18:51 PM
On Jan 28, 5:18=A0pm, Tom Shelton <tom_shel...@comcastXXXXXXX.net>
wrote:
> On 2010-01-28, Awrightus <awrigh...@gmail.com> wrote:
>
>
>
>
>
> > I'm working on a vb.net project (2008) I have and I'm trying to figure
> > out how I can create a multi-dimensional array, arraylist, dictionary,
> > etc, whatever will allow me to do what I want to do. =A0I have data lik=
e
> > the following:
>
> > Blue, Green,
> > Black, Orange
> > Yellow, Red
>
> > Essentially value/pair stuff. =A0I already have it in a dictionary, but
> > it doesn't look like a dictionary has an index value for each of the
> > keys. =A0I want to be able to reference any of these "rows" by their
> > index value and the position of the item in the row (or column). So as
> > an example, I might want to know what the 2nd index row is and the
> > value of the 1 index inside that row (or the column). =A0That would be
> > "Red". =A0Is there a way of doing this in vb.net? =A0Not looking for co=
de,
> > just the right type of object/function to us. =A0Thanks.
>
> > Steve
>
> How much data is typically going to be in this collection?
>
> --
> Tom Shelton- Hide quoted text -
>
> - Show quoted text -

Eh, could be around 50,000 or so.
0
Awrightus
1/28/2010 10:26:26 PM
On 1/28/2010 5:26 PM, Awrightus wrote:
> On Jan 28, 5:18 pm, Tom Shelton<tom_shel...@comcastXXXXXXX.net>
> wrote:
>> On 2010-01-28, Awrightus<awrigh...@gmail.com>  wrote:
>>
>>
>>
>>
>>
>>> I'm working on a vb.net project (2008) I have and I'm trying to figure
>>> out how I can create a multi-dimensional array, arraylist, dictionary,
>>> etc, whatever will allow me to do what I want to do.  I have data like
>>> the following:
>>
>>> Blue, Green,
>>> Black, Orange
>>> Yellow, Red
>>
>>> Essentially value/pair stuff.  I already have it in a dictionary, but
>>> it doesn't look like a dictionary has an index value for each of the
>>> keys.  I want to be able to reference any of these "rows" by their
>>> index value and the position of the item in the row (or column). So as
>>> an example, I might want to know what the 2nd index row is and the
>>> value of the 1 index inside that row (or the column).  That would be
>>> "Red".  Is there a way of doing this in vb.net?  Not looking for code,
>>> just the right type of object/function to us.  Thanks.
>>
>>> Steve
>>
>> How much data is typically going to be in this collection?
>>
>> --
>> Tom Shelton- Hide quoted text -
>>
>> - Show quoted text -
>
> Eh, could be around 50,000 or so.

Is the problem you don't know how many, and so you cannot declare as:

dim data0 as string (,)

If so, then perhaps one of the following:

dim data1 as List(of List(of string))
dim data2 as List(of string ())


You address your item as:
data0(2,1) or data1(2)(1) or data2(2)(1)

-- 
Mike
0
Family
1/28/2010 11:03:13 PM
On Jan 28, 6:03=A0pm, Family Tree Mike <FamilyTreeM...@ThisOldHouse.com>
wrote:
> On 1/28/2010 5:26 PM, Awrightus wrote:
>
>
>
>
>
> > On Jan 28, 5:18 pm, Tom Shelton<tom_shel...@comcastXXXXXXX.net>
> > wrote:
> >> On 2010-01-28, Awrightus<awrigh...@gmail.com> =A0wrote:
>
> >>> I'm working on a vb.net project (2008) I have and I'm trying to figur=
e
> >>> out how I can create a multi-dimensional array, arraylist, dictionary=
,
> >>> etc, whatever will allow me to do what I want to do. =A0I have data l=
ike
> >>> the following:
>
> >>> Blue, Green,
> >>> Black, Orange
> >>> Yellow, Red
>
> >>> Essentially value/pair stuff. =A0I already have it in a dictionary, b=
ut
> >>> it doesn't look like a dictionary has an index value for each of the
> >>> keys. =A0I want to be able to reference any of these "rows" by their
> >>> index value and the position of the item in the row (or column). So a=
s
> >>> an example, I might want to know what the 2nd index row is and the
> >>> value of the 1 index inside that row (or the column). =A0That would b=
e
> >>> "Red". =A0Is there a way of doing this in vb.net? =A0Not looking for =
code,
> >>> just the right type of object/function to us. =A0Thanks.
>
> >>> Steve
>
> >> How much data is typically going to be in this collection?
>
> >> --
> >> Tom Shelton- Hide quoted text -
>
> >> - Show quoted text -
>
> > Eh, could be around 50,000 or so.
>
> Is the problem you don't know how many, and so you cannot declare as:
>
> dim data0 as string (,)
>
> If so, then perhaps one of the following:
>
> dim data1 as List(of List(of string))
> dim data2 as List(of string ())
>
> You address your item as:
> data0(2,1) or data1(2)(1) or data2(2)(1)
>
> --
> Mike- Hide quoted text -
>
> - Show quoted text -

Just thought of something significant.  Every element might not be of
the same dimension.  Something like this.

Black, Red
Blue, Purple
Orange
Yellow, White
Indigo

Could the second row perhaps be null?

0
Awrightus
1/28/2010 11:50:31 PM
On 2010-01-28, Awrightus <awrightus@gmail.com> wrote:
> I'm working on a vb.net project (2008) I have and I'm trying to figure
> out how I can create a multi-dimensional array, arraylist, dictionary,
> etc, whatever will allow me to do what I want to do.  I have data like
> the following:
>
> Blue, Green,
> Black, Orange
> Yellow, Red
>
> Essentially value/pair stuff.  I already have it in a dictionary, but
> it doesn't look like a dictionary has an index value for each of the
> keys.  I want to be able to reference any of these "rows" by their
> index value and the position of the item in the row (or column). So as
> an example, I might want to know what the 2nd index row is and the
> value of the 1 index inside that row (or the column).  That would be
> "Red".  Is there a way of doing this in vb.net?  Not looking for code,
> just the right type of object/function to us.  Thanks.
>
> Steve

You might want to play with the performance, but here is a simple custom
collection that lets you access by index or by string.  I've also implemented
contains, etc...  So, take a look see if it does what you want - if not,
should at least give you a start :) as you could just make the type of the
custom collection a 2 dimmensional string array :)

Option Strict On
Option Explicit On

Imports System.Collections.ObjectModel

Module Module1

    Sub Main()
        Dim pairs As New ColorPairList()
        pairs.Add(New ColorPair("Yellow", "Red"))
        pairs.Add(New ColorPair("Blue", "Orange"))

        If Not pairs.Contains("yellow") Then
            pairs.Add(New ColorPair("Yellow", "Red"))
        End If

        Dim p1 As ColorPair = pairs("yellow")
        Dim p2 As ColorPair = pairs(1)

        Console.WriteLine(p1.Color1)
        Console.WriteLine(p2.Color1)
    End Sub

    Class ColorPair
        Private _color1 As String
        Private _color2 As String

        Public Sub New()
            '
        End Sub

        Public Sub New(ByVal color1 As String, ByVal color2 As String)
            _color1 = color1
            _color2 = color2
        End Sub

        Public Property Color1() As String
            Get
                Return _color1
            End Get
            Set(ByVal value As String)
                _color1 = value
            End Set
        End Property

        Public Property Color2() As String
            Get
                Return _color2
            End Get
            Set(ByVal value As String)
                _color2 = value
            End Set
        End Property

        Public Overrides Function Equals(ByVal obj As Object) As Boolean
            Dim other As ColorPair = TryCast(obj, ColorPair)
            If other IsNot Nothing Then
                Return StringComparer.OrdinalIgnoreCase.Compare(Color1, other.Color1) = 0
            Else
                Dim str As String = TryCast(obj, String)
                If str IsNot Nothing Then
                    Return StringComparer.OrdinalIgnoreCase.Compare(Color1, str) = 0
                End If
            End If

            Return False
        End Function

        Public Overrides Function GetHashCode() As Integer
            Return Color1.GetHashCode()
        End Function

        Public Overrides Function ToString() As String
            Return String.Format("{0}, {1}", _color1, _color2)
        End Function
    End Class

    Class ColorPairList
        Inherits Collection(Of ColorPair)

        ' this is not case senstive...
        Private _dictionary As New Dictionary(Of String, ColorPair)(StringComparer.OrdinalIgnoreCase)

        Default Public Overloads ReadOnly Property Item(ByVal color As String) As ColorPair
            Get
                Dim pair As ColorPair = Nothing
                Return If(_dictionary.TryGetValue(color, pair), pair, Nothing)
            End Get
        End Property

        Public Overloads Function Contains(ByRef color As String) As Boolean
            Return _dictionary.ContainsKey(color)
        End Function

        Protected Overrides Sub InsertItem(ByVal index As Integer, ByVal item As ColorPair)

            ' add, let it throw exception :)
            _dictionary.Add(item.Color1, item)
            MyBase.InsertItem(index, item)

        End Sub

        Protected Overrides Sub RemoveItem(ByVal index As Integer)
            _dictionary.Remove(Items(index).Color1)
            MyBase.RemoveItem(index)
        End Sub

        Protected Overrides Sub ClearItems()
            _dictionary.Clear()
            MyBase.ClearItems()
        End Sub
    End Class
End Module



-- 
Tom Shelton
0
Tom
1/28/2010 11:51:29 PM
On Jan 28, 6:51=A0pm, Tom Shelton <tom_shel...@comcastXXXXXXX.net>
wrote:
> On 2010-01-28, Awrightus <awrigh...@gmail.com> wrote:
>
>
>
>
>
> > I'm working on a vb.net project (2008) I have and I'm trying to figure
> > out how I can create a multi-dimensional array, arraylist, dictionary,
> > etc, whatever will allow me to do what I want to do. =A0I have data lik=
e
> > the following:
>
> > Blue, Green,
> > Black, Orange
> > Yellow, Red
>
> > Essentially value/pair stuff. =A0I already have it in a dictionary, but
> > it doesn't look like a dictionary has an index value for each of the
> > keys. =A0I want to be able to reference any of these "rows" by their
> > index value and the position of the item in the row (or column). So as
> > an example, I might want to know what the 2nd index row is and the
> > value of the 1 index inside that row (or the column). =A0That would be
> > "Red". =A0Is there a way of doing this in vb.net? =A0Not looking for co=
de,
> > just the right type of object/function to us. =A0Thanks.
>
> > Steve
>
> You might want to play with the performance, but here is a simple custom
> collection that lets you access by index or by string. =A0I've also imple=
mented
> contains, etc... =A0So, take a look see if it does what you want - if not=
,
> should at least give you a start :) as you could just make the type of th=
e
> custom collection a 2 dimmensional string array :)
>
> Option Strict On
> Option Explicit On
>
> Imports System.Collections.ObjectModel
>
> Module Module1
>
> =A0 =A0 Sub Main()
> =A0 =A0 =A0 =A0 Dim pairs As New ColorPairList()
> =A0 =A0 =A0 =A0 pairs.Add(New ColorPair("Yellow", "Red"))
> =A0 =A0 =A0 =A0 pairs.Add(New ColorPair("Blue", "Orange"))
>
> =A0 =A0 =A0 =A0 If Not pairs.Contains("yellow") Then
> =A0 =A0 =A0 =A0 =A0 =A0 pairs.Add(New ColorPair("Yellow", "Red"))
> =A0 =A0 =A0 =A0 End If
>
> =A0 =A0 =A0 =A0 Dim p1 As ColorPair =3D pairs("yellow")
> =A0 =A0 =A0 =A0 Dim p2 As ColorPair =3D pairs(1)
>
> =A0 =A0 =A0 =A0 Console.WriteLine(p1.Color1)
> =A0 =A0 =A0 =A0 Console.WriteLine(p2.Color1)
> =A0 =A0 End Sub
>
> =A0 =A0 Class ColorPair
> =A0 =A0 =A0 =A0 Private _color1 As String
> =A0 =A0 =A0 =A0 Private _color2 As String
>
> =A0 =A0 =A0 =A0 Public Sub New()
> =A0 =A0 =A0 =A0 =A0 =A0 '
> =A0 =A0 =A0 =A0 End Sub
>
> =A0 =A0 =A0 =A0 Public Sub New(ByVal color1 As String, ByVal color2 As St=
ring)
> =A0 =A0 =A0 =A0 =A0 =A0 _color1 =3D color1
> =A0 =A0 =A0 =A0 =A0 =A0 _color2 =3D color2
> =A0 =A0 =A0 =A0 End Sub
>
> =A0 =A0 =A0 =A0 Public Property Color1() As String
> =A0 =A0 =A0 =A0 =A0 =A0 Get
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Return _color1
> =A0 =A0 =A0 =A0 =A0 =A0 End Get
> =A0 =A0 =A0 =A0 =A0 =A0 Set(ByVal value As String)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 _color1 =3D value
> =A0 =A0 =A0 =A0 =A0 =A0 End Set
> =A0 =A0 =A0 =A0 End Property
>
> =A0 =A0 =A0 =A0 Public Property Color2() As String
> =A0 =A0 =A0 =A0 =A0 =A0 Get
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Return _color2
> =A0 =A0 =A0 =A0 =A0 =A0 End Get
> =A0 =A0 =A0 =A0 =A0 =A0 Set(ByVal value As String)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 _color2 =3D value
> =A0 =A0 =A0 =A0 =A0 =A0 End Set
> =A0 =A0 =A0 =A0 End Property
>
> =A0 =A0 =A0 =A0 Public Overrides Function Equals(ByVal obj As Object) As =
Boolean
> =A0 =A0 =A0 =A0 =A0 =A0 Dim other As ColorPair =3D TryCast(obj, ColorPair=
)
> =A0 =A0 =A0 =A0 =A0 =A0 If other IsNot Nothing Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Return StringComparer.OrdinalIgnoreCase.C=
ompare(Color1, other.Color1) =3D 0
> =A0 =A0 =A0 =A0 =A0 =A0 Else
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Dim str As String =3D TryCast(obj, String=
)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 If str IsNot Nothing Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Return StringComparer.OrdinalIgno=
reCase.Compare(Color1, str) =3D 0
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 End If
> =A0 =A0 =A0 =A0 =A0 =A0 End If
>
> =A0 =A0 =A0 =A0 =A0 =A0 Return False
> =A0 =A0 =A0 =A0 End Function
>
> =A0 =A0 =A0 =A0 Public Overrides Function GetHashCode() As Integer
> =A0 =A0 =A0 =A0 =A0 =A0 Return Color1.GetHashCode()
> =A0 =A0 =A0 =A0 End Function
>
> =A0 =A0 =A0 =A0 Public Overrides Function ToString() As String
> =A0 =A0 =A0 =A0 =A0 =A0 Return String.Format("{0}, {1}", _color1, _color2=
)
> =A0 =A0 =A0 =A0 End Function
> =A0 =A0 End Class
>
> =A0 =A0 Class ColorPairList
> =A0 =A0 =A0 =A0 Inherits Collection(Of ColorPair)
>
> =A0 =A0 =A0 =A0 ' this is not case senstive...
> =A0 =A0 =A0 =A0 Private _dictionary As New Dictionary(Of String, ColorPai=
r)(StringComparer.OrdinalIgnoreCase)
>
> =A0 =A0 =A0 =A0 Default Public Overloads ReadOnly Property Item(ByVal col=
or As String) As ColorPair
> =A0 =A0 =A0 =A0 =A0 =A0 Get
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Dim pair As ColorPair =3D Nothing
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Return If(_dictionary.TryGetValue(color, =
pair), pair, Nothing)
> =A0 =A0 =A0 =A0 =A0 =A0 End Get
> =A0 =A0 =A0 =A0 End Property
>
> =A0 =A0 =A0 =A0 Public Overloads Function Contains(ByRef color As String)=
 As Boolean
> =A0 =A0 =A0 =A0 =A0 =A0 Return _dictionary.ContainsKey(color)
> =A0 =A0 =A0 =A0 End Function
>
> =A0 =A0 =A0 =A0 Protected Overrides Sub InsertItem(ByVal index As Integer=
, ByVal item As ColorPair)
>
> =A0 =A0 =A0 =A0 =A0 =A0 ' add, let it throw exception :)
> =A0 =A0 =A0 =A0 =A0 =A0 _dictionary.Add(item.Color1, item)
> =A0 =A0 =A0 =A0 =A0 =A0 MyBase.InsertItem(index, item)
>
> =A0 =A0 =A0 =A0 End Sub
>
> =A0 =A0 =A0 =A0 Protected Overrides Sub RemoveItem(ByVal index As Integer=
)
> =A0 =A0 =A0 =A0 =A0 =A0 _dictionary.Remove(Items(index).Color1)
> =A0 =A0 =A0 =A0 =A0 =A0 MyBase.RemoveItem(index)
> =A0 =A0 =A0 =A0 End Sub
>
> =A0 =A0 =A0 =A0 Protected Overrides Sub ClearItems()
> =A0 =A0 =A0 =A0 =A0 =A0 _dictionary.Clear()
> =A0 =A0 =A0 =A0 =A0 =A0 MyBase.ClearItems()
> =A0 =A0 =A0 =A0 End Sub
> =A0 =A0 End Class
> End Module
>
> --
> Tom Shelton- Hide quoted text -
>
> - Show quoted text -

Thanks.  This should give me something to work with.
0
Awrightus
1/29/2010 1:10:21 AM
On 1/28/2010 6:50 PM, Awrightus wrote:
> On Jan 28, 6:03 pm, Family Tree Mike<FamilyTreeM...@ThisOldHouse.com>
> wrote:
>> On 1/28/2010 5:26 PM, Awrightus wrote:
>>
>>
>>
>>
>>
>>> On Jan 28, 5:18 pm, Tom Shelton<tom_shel...@comcastXXXXXXX.net>
>>> wrote:
>>>> On 2010-01-28, Awrightus<awrigh...@gmail.com>    wrote:
>>
>>>>> I'm working on a vb.net project (2008) I have and I'm trying to figure
>>>>> out how I can create a multi-dimensional array, arraylist, dictionary,
>>>>> etc, whatever will allow me to do what I want to do.  I have data like
>>>>> the following:
>>
>>>>> Blue, Green,
>>>>> Black, Orange
>>>>> Yellow, Red
>>
>>>>> Essentially value/pair stuff.  I already have it in a dictionary, but
>>>>> it doesn't look like a dictionary has an index value for each of the
>>>>> keys.  I want to be able to reference any of these "rows" by their
>>>>> index value and the position of the item in the row (or column). So as
>>>>> an example, I might want to know what the 2nd index row is and the
>>>>> value of the 1 index inside that row (or the column).  That would be
>>>>> "Red".  Is there a way of doing this in vb.net?  Not looking for code,
>>>>> just the right type of object/function to us.  Thanks.
>>
>>>>> Steve
>>
>>>> How much data is typically going to be in this collection?
>>
>>>> --
>>>> Tom Shelton- Hide quoted text -
>>
>>>> - Show quoted text -
>>
>>> Eh, could be around 50,000 or so.
>>
>> Is the problem you don't know how many, and so you cannot declare as:
>>
>> dim data0 as string (,)
>>
>> If so, then perhaps one of the following:
>>
>> dim data1 as List(of List(of string))
>> dim data2 as List(of string ())
>>
>> You address your item as:
>> data0(2,1) or data1(2)(1) or data2(2)(1)
>>
>> --
>> Mike- Hide quoted text -
>>
>> - Show quoted text -
>
> Just thought of something significant.  Every element might not be of
> the same dimension.  Something like this.
>
> Black, Red
> Blue, Purple
> Orange
> Yellow, White
> Indigo
>
> Could the second row perhaps be null?
>

I would then go with List(of List(of string)) or with a variation of 
Tom's code that adds the capability to have a null second pair string.

-- 
Mike
0
Family
1/29/2010 1:36:29 AM
On 2010-01-29, Family Tree Mike <FamilyTreeMike@ThisOldHouse.com> wrote:
> On 1/28/2010 6:50 PM, Awrightus wrote:
>> On Jan 28, 6:03 pm, Family Tree Mike<FamilyTreeM...@ThisOldHouse.com>
>> wrote:
>>> On 1/28/2010 5:26 PM, Awrightus wrote:
>>>
>>>
>>>
>>>
>>>
>>>> On Jan 28, 5:18 pm, Tom Shelton<tom_shel...@comcastXXXXXXX.net>
>>>> wrote:
>>>>> On 2010-01-28, Awrightus<awrigh...@gmail.com>    wrote:
>>>
>>>>>> I'm working on a vb.net project (2008) I have and I'm trying to figure
>>>>>> out how I can create a multi-dimensional array, arraylist, dictionary,
>>>>>> etc, whatever will allow me to do what I want to do.  I have data like
>>>>>> the following:
>>>
>>>>>> Blue, Green,
>>>>>> Black, Orange
>>>>>> Yellow, Red
>>>
>>>>>> Essentially value/pair stuff.  I already have it in a dictionary, but
>>>>>> it doesn't look like a dictionary has an index value for each of the
>>>>>> keys.  I want to be able to reference any of these "rows" by their
>>>>>> index value and the position of the item in the row (or column). So as
>>>>>> an example, I might want to know what the 2nd index row is and the
>>>>>> value of the 1 index inside that row (or the column).  That would be
>>>>>> "Red".  Is there a way of doing this in vb.net?  Not looking for code,
>>>>>> just the right type of object/function to us.  Thanks.
>>>
>>>>>> Steve
>>>
>>>>> How much data is typically going to be in this collection?
>>>
>>>>> --
>>>>> Tom Shelton- Hide quoted text -
>>>
>>>>> - Show quoted text -
>>>
>>>> Eh, could be around 50,000 or so.
>>>
>>> Is the problem you don't know how many, and so you cannot declare as:
>>>
>>> dim data0 as string (,)
>>>
>>> If so, then perhaps one of the following:
>>>
>>> dim data1 as List(of List(of string))
>>> dim data2 as List(of string ())
>>>
>>> You address your item as:
>>> data0(2,1) or data1(2)(1) or data2(2)(1)
>>>
>>> --
>>> Mike- Hide quoted text -
>>>
>>> - Show quoted text -
>>
>> Just thought of something significant.  Every element might not be of
>> the same dimension.  Something like this.
>>
>> Black, Red
>> Blue, Purple
>> Orange
>> Yellow, White
>> Indigo
>>
>> Could the second row perhaps be null?
>>
>
> I would then go with List(of List(of string)) or with a variation of 
> Tom's code that adds the capability to have a null second pair string.
>

Mine actaully already allows it - the second string in the pair is never used
in any of the comparisons or as a key.  Only the first string is used.

-- 
Tom Shelton
0
Tom
1/29/2010 2:12:54 AM
On 1/28/2010 9:12 PM, Tom Shelton wrote:
> On 2010-01-29, Family Tree Mike<FamilyTreeMike@ThisOldHouse.com>  wrote:
>> On 1/28/2010 6:50 PM, Awrightus wrote:
>>> On Jan 28, 6:03 pm, Family Tree Mike<FamilyTreeM...@ThisOldHouse.com>
>>> wrote:
>>>> On 1/28/2010 5:26 PM, Awrightus wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> On Jan 28, 5:18 pm, Tom Shelton<tom_shel...@comcastXXXXXXX.net>
>>>>> wrote:
>>>>>> On 2010-01-28, Awrightus<awrigh...@gmail.com>     wrote:
>>>>
>>>>>>> I'm working on a vb.net project (2008) I have and I'm trying to figure
>>>>>>> out how I can create a multi-dimensional array, arraylist, dictionary,
>>>>>>> etc, whatever will allow me to do what I want to do.  I have data like
>>>>>>> the following:
>>>>
>>>>>>> Blue, Green,
>>>>>>> Black, Orange
>>>>>>> Yellow, Red
>>>>
>>>>>>> Essentially value/pair stuff.  I already have it in a dictionary, but
>>>>>>> it doesn't look like a dictionary has an index value for each of the
>>>>>>> keys.  I want to be able to reference any of these "rows" by their
>>>>>>> index value and the position of the item in the row (or column). So as
>>>>>>> an example, I might want to know what the 2nd index row is and the
>>>>>>> value of the 1 index inside that row (or the column).  That would be
>>>>>>> "Red".  Is there a way of doing this in vb.net?  Not looking for code,
>>>>>>> just the right type of object/function to us.  Thanks.
>>>>
>>>>>>> Steve
>>>>
>>>>>> How much data is typically going to be in this collection?
>>>>
>>>>>> --
>>>>>> Tom Shelton- Hide quoted text -
>>>>
>>>>>> - Show quoted text -
>>>>
>>>>> Eh, could be around 50,000 or so.
>>>>
>>>> Is the problem you don't know how many, and so you cannot declare as:
>>>>
>>>> dim data0 as string (,)
>>>>
>>>> If so, then perhaps one of the following:
>>>>
>>>> dim data1 as List(of List(of string))
>>>> dim data2 as List(of string ())
>>>>
>>>> You address your item as:
>>>> data0(2,1) or data1(2)(1) or data2(2)(1)
>>>>
>>>> --
>>>> Mike- Hide quoted text -
>>>>
>>>> - Show quoted text -
>>>
>>> Just thought of something significant.  Every element might not be of
>>> the same dimension.  Something like this.
>>>
>>> Black, Red
>>> Blue, Purple
>>> Orange
>>> Yellow, White
>>> Indigo
>>>
>>> Could the second row perhaps be null?
>>>
>>
>> I would then go with List(of List(of string)) or with a variation of
>> Tom's code that adds the capability to have a null second pair string.
>>
>
> Mine actaully already allows it - the second string in the pair is never used
> in any of the comparisons or as a key.  Only the first string is used.
>

Your right, sorry.  I must have misread something there, as I thought it 
required a second string.

-- 
Mike
0
Family
1/29/2010 2:23:19 AM
Reply:

Similar Artilces: