DBNull Class

Represents a nonexistent value. This class cannot be inherited.

Inheritance Hierarchy

System.Object
  System.DBNull

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<ComVisibleAttribute(True)> _
Public NotInheritable Class DBNull _
    Implements IConvertible
[ComVisibleAttribute(true)]
public sealed class DBNull : IConvertible

The DBNull type exposes the following members.

Methods

  Name Description
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetType Gets the Type of the current instance. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetTypeCode Gets the TypeCode value for DBNull.
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 ToString() Returns an empty string (String.Empty). (Overrides Object.ToString().)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 ToString(IFormatProvider) Returns an empty string using the specified System.IFormatProvider.

Top

Fields

  Name Description
Public fieldStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 Value Represents the sole instance of the DBNull class.

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToBoolean Infrastructure. This conversion is not supported. Attempting to make this conversion throws an InvalidCastException.
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToByte Infrastructure. This conversion is not supported. Attempting to make this conversion throws an InvalidCastException.
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToChar Infrastructure. This conversion is not supported. Attempting to make this conversion throws an InvalidCastException.
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToDateTime Infrastructure. This conversion is not supported. Attempting to make this conversion throws an InvalidCastException.
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToDecimal Infrastructure. This conversion is not supported. Attempting to make this conversion throws an InvalidCastException.
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToDouble Infrastructure. This conversion is not supported. Attempting to make this conversion throws an InvalidCastException.
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToInt16 Infrastructure. This conversion is not supported. Attempting to make this conversion throws an InvalidCastException.
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToInt32 Infrastructure. This conversion is not supported. Attempting to make this conversion throws an InvalidCastException.
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToInt64 Infrastructure. This conversion is not supported. Attempting to make this conversion throws an InvalidCastException.
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToSByte Infrastructure. This conversion is not supported. Attempting to make this conversion throws an InvalidCastException.
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToSingle Infrastructure. This conversion is not supported. Attempting to make this conversion throws an InvalidCastException.
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToType Infrastructure. Converts the current DBNull object to the specified type.
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToUInt16 Infrastructure. This conversion is not supported. Attempting to make this conversion throws an InvalidCastException.
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToUInt32 Infrastructure. This conversion is not supported. Attempting to make this conversion throws an InvalidCastException.
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 IConvertible.ToUInt64 Infrastructure. This conversion is not supported. Attempting to make this conversion throws an InvalidCastException.

Top

Remarks

The DBNull class represents a nonexistent value. In a database, for example, a column in a row of a table might not contain any data whatsoever. That is, the column is considered to not exist at all instead of merely not having a value. A DBNull object represents the nonexistent column. Additionally, COM interop uses the DBNull class to distinguish between a VT_NULL variant, which indicates a nonexistent value, and a VT_EMPTY variant, which indicates an unspecified value.

The DBNull type is a singleton class, which means only one DBNull object exists. The DBNull.Value member represents the sole DBNull object. DBNull.Value can be used to explicitly assign a nonexistent value to a database field, although most ADO.NET data providers automatically assign values of DBNull when a field does not have a valid value. You can determine whether a value retrieved from a database field is a DBNull value by passing the value of that field to the DBNull.Value.Equals method. However, some languages and database objects supply methods that make it easier to determine whether the value of a database field is DBNull.Value. These include the Visual Basic IsDBNull function and the Convert.IsDBNull method.

Do not confuse the notion of nulla null reference (Nothing in Visual Basic) in an object-oriented programming language with a DBNull object. In an object-oriented programming language, nulla null reference (Nothing in Visual Basic) means the absence of a reference to an object. DBNull represents an uninitialized variant or nonexistent database column.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.