0

I was going through a class library in one of our projects.

i came across statements like public int? variablename

What does this mean..I am going to create classes for new application refering current

application .

So ,i would like to know what it is and in which scenarios we can use and is it not

possible to avoid it

Sai Avinash
  • 4,683
  • 17
  • 58
  • 96

4 Answers4

2

int? means that it is "nullable". Being nullable allows you to have null values in your int.

Check out this link if you need to understand a bit more,

http://msdn.microsoft.com/en-us/library/2cf62fcy%28VS.80%29.aspx

How do nullable types work in C#?

Community
  • 1
  • 1
trueamerican420
  • 211
  • 2
  • 10
1

The question mark is a shortcut for Nullable<> (MSDN).

int? is the same as Nullable<int>

nvoigt
  • 75,013
  • 26
  • 93
  • 142
1

That is a nullable type msdn.microsoft.com/en-us/library/1t3y8s4s(v=vs.80).aspx

Stephen Gilboy
  • 5,572
  • 2
  • 30
  • 36
0

This means that the variable is nullable

Ctrl_Alt_Defeat
  • 3,933
  • 12
  • 66
  • 116