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

Somewhere in the pre-existing project(VS2008), (the one that i have to maintain ;-[ ), i see some coding as follows:-


C#
public int? GetInt(object p_objValue)
{
}


Here, What does this "int?" means ?

The question mark with "int" is not mentioned by mistake.

HELP !!
Posted
Updated 29-Sep-11 19:52pm
v3

In your case it represents that the method can return null as value.



int? means, it is a "boxed" integer value. That means. a int? is nullable!
C#
int i1=1; //ok
int i2=null; //not ok
int? i3=1; //ok
int? i4=null; //ok



check this link
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/4107d47b-b1c4-495d-a67a-6ad3f2e7adbc[^]
 
Share this answer
 
v4
int? : allow null value and int value
int : allow only int value


for ex :

int? i = null; // it worked
int i = null; // it gives error
 
Share this answer
 
v2
int?i, allow you to store null value in i or any other integer value

this is called nullable type.

read more about nullable;

http://www.c-sharpcorner.com/UploadFile/prasoonk/NullableTypeinCSharp06042009092324AM/NullableTypeinCSharp.aspx[^]
 
Share this answer
 

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