As I said,
double x;
now i want to assign
x = NULL, how can I do this? I saw some other answers, but could not understand them, why the opening of this topic.
You must declare it as a type with a null value:
double? x; x = null;
Invalid types, such as double, cannot be null
Cannot set null to odd type
You can use NaN(rather than a number) for non-nullabledouble
NaN
double
double x; x = double.NaN;
Nullable types - System.Nullable(Of T). null. , Nullable, "Nullable of Int32", -2147483648 2147483647 . Nullable true false null. , , , . , true false, undefined.
? amount = null;http://msdn.microsoft.com/en-us/library/vstudio/2cf62fcy.aspx
? amount = null;
http://msdn.microsoft.com/en-us/library/vstudio/2cf62fcy.aspx
:
Why can't I set the nullable int to null in a three-dimensional if statement? Zero types and ternary operator: why? 10: null` is forbidden?
Short answer: you cannot.
A doublecan only contain a valid double-precision floating point value.
use double? x;
and set the null value to x as
x = null;