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,623
  • 17
  • 55
  • 94

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
  • 201
  • 2
  • 10
1

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

int? is the same as Nullable<int>

nvoigt
  • 68,786
  • 25
  • 88
  • 134
1

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

Stephen Gilboy
  • 4,662
  • 1
  • 32
  • 32
0

This means that the variable is nullable

Ctrl_Alt_Defeat
  • 3,801
  • 12
  • 59
  • 110