Solved

Difference between int? and int decleration ??

Posted on 2007-04-11
3
250 Views
Last Modified: 2010-04-15
Please explain the difference between:

int i;
and
int? i;

Best regards,
Kaj Bromose
0
Comment
Question by:bromose
[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
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Thalox earned 125 total points
ID: 18888566
? after a type means it can be null.
if you assign null "normal" variable (e.g from a database) this will throw an exception. a nullable type will not.

for more info have a look at

http://msdn2.microsoft.com/en-us/library/1t3y8s4s.aspx

Thalox
0
 
LVL 16

Assisted Solution

by:AlexNek
AlexNek earned 125 total points
ID: 18888581
"A nullable type can represent the normal range of values for its underlying value type, plus an additional null value"
http://msdn2.microsoft.com/en-us/library/1t3y8s4s.aspx

Nullable value types (denoted by a question mark, ie int? i = null;) which add null to the set of allowed values for any value type. This provides improved interaction with SQL databases, which can have nullable columns of types corresponding to C# primitive types: an SQL INTEGER NULL column type directly translates to the C# int?.

http://en.wikipedia.org/wiki/Nullable_Types
0
 
LVL 16

Expert Comment

by:AlexNek
ID: 18888584
You type more quickly. :)
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 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