Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi All,
 

How to paas a null value in double variable e.g.
 

Double abc=null;
or Double abc="";
 

thanks
 
mohd wasif
Posted 27-Jun-12 1:13am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Use Nullable Types if you want to assign NULL.
 
For example:
int? i = 10;
double? d1 = 3.14;
bool? flag = null;
char? letter = 'a';
 
For more information on Nullable Types look into following links:
http://www.blackwasp.co.uk/CSharpNullableDataTypes.aspx[^]
http://www.codeguru.com/csharp/csharp/cs_syntax/operators/article.php/c10393/Using-Nullable-Types-in-C.htm[^]
http://msdn.microsoft.com/en-us/library/2cf62fcy.aspx[^]
  Permalink  
Comments
Rahul Rajat Singh at 27-Jun-12 6:43am
   
good answer. +5.
Vani Kulkarni at 27-Jun-12 6:47am
   
Thanks Rahul!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

double is a value type. value types dont really have null values. but you can have nullable double by using this syntax.
 
Nullable<Double> d = null;
 
this will work same as a double. try using it. Just remember nullable types are immutable. but since you are using double it wont be a big problem for you.
 
P.S. the shorthand of what i just told you is like
 
Double? d = null;
 
it means the same. just a syntactic sugar for the first one.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 Mathew Soji 195
4 Afzaal Ahmad Zeeshan 170
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,777
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 27 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100