473,473 Members | 2,153 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 955
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chris S. | last post by:
I'm trying to make a graphical editor and browser for Pickled files. One aspect I'm not sure about is how to detect multiple references to the same data. For instance, say I had the Pickled...
4
by: Mark D. Anderson | last post by:
About a month ago Richard Cornford did an interesting analysis of a memory leak in jscript (internet explorer) when there are "circular" references between DOM objects and (real) jscript objects:...
2
by: brazilnut52 | last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better I have created a simple COM DLL in .NET by using the COM class...
5
by: Michael Moreno | last post by:
Hello, In a class I have this code: public object Obj; If Obj is a COM object I would like to call in the Dispose() method the following code: ...
26
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized...
17
by: Divick | last post by:
Hi, I am designing an API and the problem that I have is more of a design issue. In my API say I have a class A and B, as shown below class A{ public: void doSomethingWithB( B * b) { //do...
9
by: ziman137 | last post by:
Hi all, The results from following codes got me a bit confused. #include <stdio.h> #include <iostream> using namespace std; struct A {
2
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
3
by: Eric Mahurin | last post by:
Is there a standard way to get a descriptor object for an arbitrary object attribute - independent of whether it uses the descriptor/ property protocol or not. I want some kind of...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.