471,336 Members | 1,254 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,336 software developers and data experts.

Object reference question

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[i].Length);j++)
5 {
6 intArray[i][j]=UInt32.Parse(Sample[i]
[j],System.Globalization.NumberStyles.Integer);

}
}

What am I doing wrong?
Jun 27 '08 #1
4 908
"AMP" <am******@gmail.comwrote in message
news:11**********************************@i76g2000 hsf.googlegroups.com...
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[i].Length);j++)
5 {
6 intArray[i][j]=UInt32.Parse(Sample[i]
[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[i] = new uint[Sample[i].Length];

--
Anthony Jones - MVP ASP/ASP.NET
Jun 27 '08 #2
AMP
On Apr 25, 12:40*pm, "Anthony Jones" <A...@yadayadayada.comwrote:
"AMP" <ampel...@gmail.comwrote in message

news:11**********************************@i76g2000 hsf.googlegroups.com...


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[i].Length);j++)
* 5 * * * * * * * {
* 6 * * * * * * * * * *intArray[i][j]=UInt32.Parse(Sample[i]
[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[i] = new uint[Sample[i].Length];

--
Anthony Jones - MVP ASP/ASP.NET- Hide quoted text -

- Show quoted text -
Perfect,
Thanks!!
Jun 27 '08 #3
On Fri, 25 Apr 2008 09:16:01 -0700, AMP <am******@gmail.comwrote:
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
First of all, you presumably mean "on line 2". Secondly, all you've
created on line 2 is an array of arrays. Each individual array hasn't
itself been initialized yet, so when you try to index one with "j", you
get the error reported.

You need a new line between 3 and 4:

intArray[i] = new uint[Sample[i].Length];

I think that should fix your issue.

Pete
Jun 27 '08 #4
Peter Duniho wrote:
On Fri, 25 Apr 2008 09:16:01 -0700, AMP <am******@gmail.comwrote:
>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
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Chris S. | last post: by
5 posts views Thread by Michael Moreno | last post: by
26 posts views Thread by yb | last post: by
17 posts views Thread by Divick | last post: by
3 posts views Thread by Eric Mahurin | last post: by
275 posts views Thread by Astley Le Jasper | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.