Re: Multidimensional ArrayList how to?

From: SpotNet (SpotNet_at_msnews.grp)
Date: 10/16/04


Date: Sat, 16 Oct 2004 16:36:32 +1000

Thanks Daniel, I'm trying to populate the array

GetDataMatrix[0,0].Add(15); throws the exception, I've got the impression
that GetDataMatrix[0,0].Add(15) method, adds the int 15 (as an object) to
the array. Inferring form your response from the declaration,

System.Collections.ArrayList[,] GetDataMatrix = New
System.Collections.ArrayList[10, 3];

I have to instantiate;
GetDataMatrix[0,0], GetDataMatrix[1,0], ...,GetDataMatrix[9,2] (in a loop of
course) and then assign them values?

Thanks again Daniel you've got me closer, I'll try it out...

Regards,
SpotNet

"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:%23Ezg8c0sEHA.3788@TK2MSFTNGP15.phx.gbl...
:
: "SpotNet" <SpotNet@msnews.grp> wrote in message
: news:%23j1yFQ0sEHA.3460@TK2MSFTNGP15.phx.gbl...
: > Hi NewsGroup;
: >
: > Trying to construct a Multidimensional (2D more specifically) populated
: > from
: > an OleDbDataReader. Reason I'm using an ArrayList is I do not know the
: > size
: > of the first dimension (being rows), here's my final attempt below;
: >
: > System.Collections.ArrayList[,] GetDataMatrix = New
: > System.Collections.ArrayList[10, 3]; //Let's just say 10, 3
: >
: > Keeping it brief and simple excuse the syntax,
: >
: > GetDataMatrix[0,0].Add(15);
: >
: > Throws an exception right at me stating that, 'Object reference is not
an
: > instance of the object'. If only 'System.Collections.ArrayList' could
: > talk
: > 'cause I have a few hard words for it, well the multi-dimensional case
: > anyway. What am I doing wrong?
: >
:
: Out of curiosity, are you populating the ArrayList[] members? All you are
: showing here is the creation of the array. ALl of its members will be null
: until you explicitly instantiate them.
: >
:
:



Relevant Pages

  • Re: regex question - trying to find ".mp3" in a SELECT box
    ... But `Array' is a Function object reference. ... Establish a new execution context using F's FormalParameterList, ... Since is not a primitive value, the exception should be thrown. ... | 5.2 Algorithm Conventions ...
    (comp.lang.javascript)
  • Re: An isArray test (and IE bugs)
    ... is not 'Array' must not be an Array, ... You have no choice but to catch every exception that is thrown in a - try - block, but only the exceptions that you expected to be catching should be handled in the - catch - block. ... That suggests that each - catch - block should contain the code to identify the exact type and nature of the exception thrown so that all the exceptions that you did not expect to be catching can be re-thrown. ... So while you could examine the strings in an given set of browsers/browser configurations you are going to hard pressed to be in a position to identify the exception in a browser that you have never seen. ...
    (comp.lang.javascript)
  • Re: Representing Dynamic Arrays in VB.NET
    ... At first I thought to use a three-dimensional array, but that quickly fell apart. ... public xRec as string =vbnullstring ' define dynamic array somewhere ... catch ex as exception ... set (byval value as string) ...
    (comp.databases.pick)
  • How do you store a stoopid array in the stoopid ViewState?
    ... Object reference not set to an instance of an object. ... An unhandled exception occurred during the execution of the ... Is there any way to create an immediate array in C#? ... public void Page_Init (object sender, ...
    (microsoft.public.dotnet.languages.csharp)
  • (Re): Which constructor is used when instantiating an array of objs ?
    ... "How can I instantiate an array of objects, ... > System.Array object so therefore none of the MyPointC constructors are ... >> you just comment out the non static parameterless constructor) and the ...
    (microsoft.public.dotnet.languages.csharp)

Loading