Object reference question

A

AMP

Hello,
I have this procedure to convert a Multidimentional string array to an
int but I get an error on line 6
"Object reference not set to an instance of an object".But Ive created
my object on line 1
int i = 0;
1 uint[][] intArray = new uint[Sample.Length][];
2 for (i=0;i<(Sample.Length);i++)
3 {
4 for(int j=0;j<(Sample.Length);j++)
5 {
6 intArray[j]=UInt32.Parse(Sample
[j],System.Globalization.NumberStyles.Integer);

}
}

What am I doing wrong?
 
A

Anthony Jones

AMP said:
Hello,
I have this procedure to convert a Multidimentional string array to an
int but I get an error on line 6
"Object reference not set to an instance of an object".But Ive created
my object on line 1
int i = 0;
1 uint[][] intArray = new uint[Sample.Length][];
2 for (i=0;i<(Sample.Length);i++)
3 {
4 for(int j=0;j<(Sample.Length);j++)
5 {
6 intArray[j]=UInt32.Parse(Sample
[j],System.Globalization.NumberStyles.Integer);

}
}

What am I doing wrong?


This isn't a multidimentional array its an array of arrays of uints.

Just before line 4 you need:-

intArray = new uint[Sample.Length];
 
A

AMP

Hello,
I have this procedure to convert a Multidimentional string array to an
int but I get an error on line 6
"Object reference not set to an instance of an object".But Ive created
my object on line 1
                 int i = 0;
  1             uint[][] intArray = new uint[Sample.Length][];
  2            for (i=0;i<(Sample.Length);i++)
  3                 {
  4                for(int j=0;j<(Sample.Length);j++)
  5               {
  6                    intArray[j]=UInt32.Parse(Sample
[j],System.Globalization.NumberStyles.Integer);

               }
               }
What am I doing wrong?

This isn't a multidimentional array its an array of arrays of uints.

Just before line 4 you need:-

intArray = new uint[Sample.Length];


Perfect,
Thanks!!
 
H

Hilton

Peter Duniho wrote:
Hello,
I have this procedure to convert a Multidimentional string array to an
int but I get an error on line 6
"Object reference not set to an instance of an object".But Ive created
my object on line 1

int i = 0;
1 uint[][] intArray = new uint[Sample.Length][];

First of all, you presumably mean "on line 2".

Real software engineers start counting at zero. ;)

Hilton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top