Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Difference between int? and int decleration ??

Posted on 2007-04-11
3
Medium Priority
?
253 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 500 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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

688 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