ECMA-334: 11.4.1 Members
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
| C# Language Specification |
|
| © 2006 ECMA International |
11.4.1 Members
An instance of a nullable type T? has two public read-only properties:
- A
HasValueproperty of typebool
- A
Valueproperty of typeT
An instance for which HasValue is true is said to be non-null. A non-null instance contains a known value
and Value returns that value.
An instance for which HasValue is false is said to be null. Attempting to read the Value of a null instance
causes a System.InvalidOperationException to be thrown.
In addition to the default constructor, every nullable type T? has a public constructor that takes a single
argument of type T. Given a value x of type T, a constructor invocation of the form
new T?(x)
creates a non-null instance of T? for which the Value property is x.
It is never necessary to explicitly invoke a nullable type’s constructor, since equivalent functionality is
provided as an implicit conversion from T to T?.