How to assign a Null value to a variable of type Non-Nullable in C #?

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.

+5
source share
5 answers

You must declare it as a type with a null value:

double? x;
x = null;

Invalid types, such as double, cannot be null

+11
source

Cannot set null to odd type

You can use NaN(rather than a number) for non-nullabledouble

double x;
x = double.NaN;
+7
source

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

:

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?

+1
source

Short answer: you cannot.

A doublecan only contain a valid double-precision floating point value.

0
source
use 
double? x;

and set the null value to x as

x = null;
0
source

All Articles