I am trying to implement Nullable type. But below mentioned code doesn\'t support null value for valuetype datatypes.
using System;
using System.Runtime;
using S
Assigning null
to Nullable
is just a syntactic sugar for assigning new Nullable
, it's part of C# language, and you can't add that feature to you custom type.
C# spec,
4.1.10 Nullable types
A nullable type can represent all values of its underlying type plus an additional null value. A nullable type is written T?, where T is the underlying type. This syntax is shorthand for System.Nullable, and the two forms can be used interchangeably.
6.1.5 Null literal conversions
An implicit conversion exists from the null literal to any nullable type. This conversion produces the null value (§4.1.10) of the given nullable type.