Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

What is "int?"  ??

Posted on 2012-03-22
7
Medium Priority
?
356 Views
Last Modified: 2012-03-22
In C#:

 public int? blue_green_apps { get; set; }


why the "?" after the int?

Not familiar with this syntax.
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 9

Assisted Solution

by:joshbula
joshbula earned 1600 total points
ID: 37753142
It just means it's nullable.  It either has value (the value of the int) or can have no value (null).
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 37753212
How long has this syntax been around?

Is it unique to MVC or is it part of C# everywhere?
0
 
LVL 18

Accepted Solution

by:
Anil Golamari earned 400 total points
ID: 37753273
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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 9

Expert Comment

by:joshbula
ID: 37753311
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
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 37753346
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
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 37753353
Accepted and Assisted solutions are backwards.  Not the points, just the distinction of Accepted vs Assisted.
0
 
LVL 40
ID: 37755657
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

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question