What is "int?" ??

In C#:

 public int? blue_green_apps { get; set; }


why the "?" after the int?

Not familiar with this syntax.
LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?
 
Anil GolamariConnect With a Mentor Commented:
http://msdn.microsoft.com/en-us/library/b3h38hb0%28v=vs.80%29.aspx

Just more information to Joshbula already mentioned above regarding int?

This syntax is supported right now .Net 2.0 framework.
0
 
joshbulaConnect With a Mentor Commented:
It just means it's nullable.  It either has value (the value of the int) or can have no value (null).
0
 
Tom KnowltonWeb developerAuthor Commented:
How long has this syntax been around?

Is it unique to MVC or is it part of C# everywhere?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
joshbulaCommented:
I'm not sure how long it's been around, and I'm pretty sure it's part of C# everywhere.  There's even a way to do it in Visual Basic as well, but I think the question mark goes after the variable instead.
0
 
Tom KnowltonWeb developerAuthor Commented:
I'm not sure how long it's been around, and I'm pretty sure it's part of C# everywhere.  There's even a way to do it in Visual Basic as well, but I think the question mark goes after the variable instead.

Thanks for the follow-up.

Thank you both for your time!
0
 
Tom KnowltonWeb developerAuthor Commented:
Accepted and Assisted solutions are backwards.  Not the points, just the distinction of Accepted vs Assisted.
0
 
Jacques Bourgeois (James Burger)PresidentCommented:
Yes, you can do it in VB by putting the ? after the name of the variable.

But personnally, I do not like that syntax, either in VB or in C#, because it is simply a shortcut to declaring a variable of the Nullable type:

public Nullable<int> blue_green_apps {get; set;}

The result is the same (int? creates a Nullable<int>), but the "standard" declaration makes it easier for everybody to understand what is happening.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.