mscorlib 2.0.0.0 4.0.0.0 DefaultConstructorConstraint NotNullableValueTypeConstraint System.ValueType System.ValueType To be added.

Represents a nullable value type. An instance of can contain a value of type or an indication that the instance contains no value. Upon boxing, if it contains no value, it will be converted to the null reference; otherwise, it will be converted to a boxed T. [Note: Because of the constraint on the generic parameter, cannot be of type for any . end note]

The value type represents a value of a given type or an indication that the instance contains no value. Such a nullable type is useful in a variety of situations, such as in denoting nullable columns in a database table or optional attributes in an XML element. The runtime transforms instances without values into true nulls when performing a box operation; instances with values are transformed into boxed 's containing the 's Value.

An instance of has two properties, and . is used to determine whether the current instance currently has a value. It returns or , and never throws an exception. returns the current value of the instance, provided it has one (i.e., is ); otherwise, it throws an exception.

In addition to the above properties, there is a pair of methods, both overloads of . The version taking no arguments returns the instance's current value, if it has one; otherwise, it returns the default value of type . The version taking an argument of type returns the instance's current value, if it has one; otherwise, it returns the default value argument passed to it.

Applying to an instance that has the default initial value, causes false to be returned.

- Constructor
  The initial value of the new instance.

  Constructs and initializes a new instance of giving it the specified initial value.

  Once this constructor has executed, applying to the new instance returns .

  2.0.0.0
  4.0.0.0
- Method
  System.Boolean `` To be added.

  Determines whether the current instance and the specified represent the same type and value.

  The following table defines the conditions under which the return value is or :

  Returned Value
  HasValue Condition obj.HasValue Condition
  The current instance and have different types. The current instance and have different types.
  is .
  is .

  This method overrides .

  2.0.0.0
  4.0.0.0
- Method
  System.Int32

  Generates a hash code for the current instance.

  If is , a containing the hash code for the value of the current instance is returned; otherwise, 0 is returned.

  The algorithm used to generate the hash code is unspecified.

  This method overrides .

  2.0.0.0
  4.0.0.0
- Method
  T

  Returns the value of the current instance, or if it has none, returns the default value for the type .

  A value of type , which is either the value of the current instance, or if it has none, the default value for the type (i.e., all-bits-zero).

  allows a value other than the default value to be returned if the current instance contains no value.

  2.0.0.0
  4.0.0.0
- Method
  T `` To be added.

  Returns the value of the current instance, or if it has none, returns .

  A value of type , which is either the value of the current instance, or if it has none, the value of .

  allows the default value for type to be returned if the current instance contains no value.

  2.0.0.0
  4.0.0.0
- Property
  System.Boolean

  Indicates whether the current instance contains a value.

  if the current instance contains a value; otherwise .

  If is , the instance contains a value, and returns that value.

  If is , the instance contains no value, and an attempt to read results in a exception. A call to returns the default value.

  This property is read-only.

  2.0.0.0
  4.0.0.0
- Method
  T `` The value to convert to type .

  Perform an explicit conversion of a value to type .

  The value, if any, of the specified nullable value. Otherwise, a is thrown.

  The conversion implemented by this method corresponds exactly to obtaining the value of the property.

  is . 2.0.0.0 4.0.0.0
- Method
  System.Nullable<T> `` The value to convert to .

  Perform an implicit conversion of a value to .

  A with the specified value.

  The conversion implemented by this method corresponds exactly to invoking the constructor.

  2.0.0.0
  4.0.0.0
- Method
  System.String

  Returns a representation of the value of the current instance.

  If is true, is returned; otherwise, is returned.

  This method overrides .

  2.0.0.0
  4.0.0.0
- Property
  T

  Gets the value, if any, of the current instance.

  The value of the current instance.

  If is , the instance contains a value, and returns that value.

  If is , the instance contains no value, and an attempt to read results in an exception.

  This property is read-only.

  is . 2.0.0.0 4.0.0.0