Click here to Skip to main content
15,879,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi evryone,

int[] users_NoVhInfo= new int[dynamically];
//dynamically m getting size of array and assigining only some values other value remains zero
for Loop
{
users_NoVhInfo[i] = Value; // it's only for example.its wrking 
}
//

function calling(users_NoVhInfo); /// ERROR.ERROR
.
.
..
void calling(int[] users_NoVhInfo)
{
...........................
}


in above code m creating array object which is collecting some values..
and it will pass through calling function... but at the tim of calling it is giving ERROR "OBJECT REFERNCE NOT SET TO AN INSTANCE OF AN OBJECT".........how i can solve this problem...its urgent guys
Posted
Updated 16-Jul-10 20:31pm
v3

Assuming the code snippet provided is some mangled psuedo code. Check your for loop is actually doing something along the lines of:

C#
int[] users_NoVhInfo= new int[10];
for(int i=0;i<10;i++)
{
    users_NoVhInfo[i]=i;
}



And you're then calling a function passing in the array, then you shouldn't see that error (due to the array). I would follow what's happening to that array very carefully using the VS debugger.
 
Share this answer
 
I don't think this is the right way to define an array of 10 integers:
C++
users_NoVhInfo[i] = {1,2,3,4,.....};


Have a look at array declaration and initialization here:http://msdn.microsoft.com/en-us/library/aa288453(VS.71).aspx[^]

Rectify your code and then post your experience.
 
Share this answer
 
Comments
Nish Nishant 16-Jul-10 12:51pm    
Reason for my vote of 5
Worth 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900