NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DBNull, Missing and Empty

System.DBNull, System.Missing and System.Empty are special singleton classes; that is, there is only one instance of each of these types in the system at any given time. That instance is stored in the static member named “Value” on each of these types. These singleton classes have special semantics when used in Reflection:

DBNull

A DBNull is never equal to anything (including another DBNull). DBNull is similar to database null. It is used in database applications to indicate the absence of a known value. The System.Convert.ToXXX methods throw an InvalidCastException when called with a DBNull argument. Convert.IsDBNull(Object obj) returns true if the argument is a DBNull. DBNull is used internally to indicate that a parameter does not have a default value. This is necessary because a parameter can have a default value that is null.

Missing

Error. Used in reflection for default arguments. All of the System.Convert.ToXXX methods throw an InvalidCastException when called with a Missing argument. The method argument Missing indicates that the default value for this argument should be used.

Empty

The universal zero, which represents values such as 0, 0.0, "", and so on. For the integral types, its value is 0; for characters, it is ‘\000’; for floating and fixed-point types, it is 0.0, and for object references, it is null. The method argument Empty is automatically coerced to any type as a “zero” value as previously defined.

When a managed object is passed to COM, the runtime’s marshaling service automatically converts the object to a COM Variant with the proper variant type. Marshaling is also done when COM variants are passed into managed code. In that case, the COM variant is converted to the proper managed object. The following table shows Variant.DBNull, Variant.Empty, and Variant.Missing are marshaled by the runtime's marshaling service.

NGWS Type COM variant type
System.DBNull VT_NULL
System.Empty VT_EMPTY
System.Missing VT_ERROR with scode = DISP_E_PARAMNOTFOUND