int? this represent the null value.. means you can pass null value in your integer variable. otherwise if you declare simply int then it will give Nullreference exception.. when it get nothing.
int? num2 = null;--- This is correct
int num2 = null;----This is incorrect;
Hope this will helpful to you
amitpatel.it
SLStrozier
What does the "?" mean in this statement
It mean that variable is nallable, so you can assing any null value with this variable.
Please click "Mark as Answer" if this helped you.
My Blog: http://shivaniaspnet.blogspot.in
"The ?? operator is called the
null-coalescing operator and is used to define a
default value for nullable value types or reference types.
It returns the left-hand operand if the operand is
not null; otherwise it returns the right operand.
g.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
SLStrozier
Member
11 Points
54 Posts
public int? variableName
Jun 19, 2012 11:50 AM|LINK
What does the "?" mean in this statement
Jack Hunt
Participant
1270 Points
713 Posts
Re: public int? variableName
Jun 19, 2012 11:51 AM|LINK
if you define
int i //than its not nullable
and
int? i //its nullable you can give to it null value
mit's Website
Mitesh N Vaishnav
amitpatel.it
Star
7976 Points
1865 Posts
Re: public int? variableName
Jun 19, 2012 11:56 AM|LINK
It mean that variable is nallable, so you can assing any null value with this variable.
MCPD Enterprise and Web Application
MCTS Web, Window and Enterprise Application
shivani.gupt...
Participant
883 Points
315 Posts
Re: public int? variableName
Jun 19, 2012 01:13 PM|LINK
Check following:
http://msdn.microsoft.com/en-us/library/2cf62fcy(v=vs.80).aspx
int? this represent the null value.. means you can pass null value in your integer variable. otherwise if you declare simply int then it will give Nullreference exception.. when it get nothing.
int? num2 = null;--- This is correct
int num2 = null;----This is incorrect;
Hope this will helpful to you
My Blog: http://shivaniaspnet.blogspot.in
gerrylowry
All-Star
20525 Points
5713 Posts
Re: public int? variableName
Jun 19, 2012 02:20 PM|LINK
@ SLStrozier
welcome to forums.asp.net.
http://lmgtfy.com/?q=.net+nullable+types
here are some articles that are worth your time to read:
http://www.codeproject.com/Articles/275471/Nullable-Types-in-Csharp-Net
"there are some scenarios where we require value type to hold null"
http://www.codeproject.com/Articles/269358/Exploring-Nullable-types-Part-1
http://msdn.microsoft.com/en-us/library/ms366789.aspx "How to: Identify a Nullable Type (C# Programming Guide)"
http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx "Nullable Types (C# Programming Guide)"
http://msdn.microsoft.com/en-us/library/ms173224.aspx "?? Operator (C# Reference)"
"The ?? operator is called the null-coalescing operator and is used to define a default value for nullable value types or reference types.
It returns the left-hand operand if the operand is not null; otherwise it returns the right operand.
g.