Click here to Skip to main content
15,911,848 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
What does the following line means ? Please explain or refer...


C#
int candidateID;
object[] param = new object[1]
 {
 candidateID 

};




Regards.
Posted
Updated 1-Oct-11 21:55pm
v2

Apart from what has been already pointed out to you this code would'nt even compile. Using a variable which has not yet been assigned to is a compile time error.

-MRB
 
Share this answer
 
What is does is create variable which can reference an array of objects, called param, assigns a new array array of objects (containing a single object) to it, and predefines the contents of that object array to a single integer (candidateID)

You end up with param referring to a single element array of objects which contains an integer.

This is a lot easier to explain with pictures...:laugh:
 
Share this answer
 
Comments
shikhar gilhotra 2-Oct-11 4:01am    
ok , so pls show the picture reference...
Manfred Rudolf Bihy 2-Oct-11 4:20am    
You forgot to mention that the int gets boxed into an Integer object, though I thoroughly doubt that OP would get the picture.
Oh wait you haven't supplied a picture yet :-P
OriginalGriff 2-Oct-11 5:05am    
I've drawn it - it's waiting here on my desk for him to come round and view :laugh:
You have initialized a single element array and added one value to it.
That one value is the value inside variable candidateID and is zero in this case.

Also, read here[^].
 
Share this answer
 
Comments
Manfred Rudolf Bihy 2-Oct-11 4:26am    
Doesn't using an unassigned variable produce a compiler error? The only way I've seen this work is passing an unassigned variable into an out parameter.

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