System.DBNull Class

Assembly: Mscorlib.dll
Namespace: System
Summary
Represents a null value.
C# Syntax:
[Serializable]
public sealed class DBNull : ISerializable, IConvertible
Thread Safety
Public static (non-instance) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
Remarks
This class is used to indicate the absence of a known value, typically in a database application.

In database applications, a null object is a valid value for a field. This class differentiates between a null value (a null object) and an uninitialized value (the DBNull.Value instance). For example, a table can have records with uninitialized fields. By default, these uninitialized fields have the DBNull value.

This class is also used in COM Interop to distinguish between a VT_NULL variant, which is associated with a null object, and a VT_EMPTY variant, which is associated with the DBNull.Value instance.

DBNull is never equal to anything.

DBNull is a singleton class, which means only one instance of this class can exist. That sole instance is DBNull.Value.

Data intensive applications accessing SQL databases must use the System.Data.SqlTypes classes, which have inherent support for null values.

See also:
System Namespace | Convert.DBNull | Convert.IsDBNull | VarEnum | System.Data.SqlTypes

System.DBNull Member List:

Public Fields
Value Represents the sole instance of the DBNull class.
Public Methods
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetObjectData Implements the ISerializable interface and returns the data needed to serialize the DBNull object.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
GetTypeCode
ToString Overloaded:
ToString()

Overridden:
Returns an empty string ( String.Empty).
ToString Overloaded:
ToString(IFormatProvider provider)

Returns an empty string using the specified IFormatProvider.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.DBNull Member Details

Field: Value
Summary
Represents the sole instance of the DBNull class.
C# Syntax:
public static readonly DBNull Value;
Remarks
DBNull is a singleton class, which means only this instance of this class can exist.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~DBNull();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetObjectData(
   SerializationInfo info,
   StreamingContext context
)
Summary
Implements the ISerializable interface and returns the data needed to serialize the DBNull object.
C# Syntax:
public void GetObjectData(
   SerializationInfo info,
   StreamingContext context
);
Parameters:

info

A SerializationInfo object containing information required to serialize the DBNull object.

context

A StreamingContext object containing the source and destination of the serialized stream associated with the DBNull object.

Exceptions
Exception Type Condition
ArgumentNullException info is null.
Implements:
ISerializable.GetObjectData
See also:
ISerializable | SerializationInfo | StreamingContext

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetTypeCode()
Summary
Gets the TypeCode value for DBNull.
C# Syntax:
public TypeCode GetTypeCode();
Return Value:
The TypeCode value for DBNull, which is TypeCode.DBNull.
Implements:
IConvertible.GetTypeCode
See also:
TypeCode

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Overloaded Method: ToString()
Summary
Returns an empty string ( String.Empty).
C# Syntax:
public override string ToString();
Return Value:
An empty string ( String.Empty).
See also:
String.Empty

Return to top


Overloaded Method: ToString(
   IFormatProvider provider
)
Summary
Returns an empty string using the specified IFormatProvider.
C# Syntax:
public string ToString(
   IFormatProvider provider
);
Parameters:

provider

The IFormatProvider to be used to format the return value. -or-

null to obtain the format information from the current locale setting of the operating system.

-or-

null to obtain the format information from the current locale setting of the operating system.

Return Value:
An empty string ( String.Empty).
Implements:
IConvertible.ToString
See also:
String.Empty

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.