mscorlib(4.0.0.0) API with additions
DBNull.cs
3 using System.Security;
4 
5 namespace System
6 {
9  [ComVisible(true)]
10  public sealed class DBNull : ISerializable, IConvertible
11  {
13  public static readonly DBNull Value = new DBNull();
14 
15  private DBNull()
16  {
17  }
18 
19  private DBNull(SerializationInfo info, StreamingContext context)
20  {
21  throw new NotSupportedException(Environment.GetResourceString("NotSupported_DBNullSerial"));
22  }
23 
29  [SecurityCritical]
31  {
32  UnitySerializationHolder.GetUnitySerializationInfo(info, 2, null, null);
33  }
34 
37  public override string ToString()
38  {
39  return string.Empty;
40  }
41 
46  public string ToString(IFormatProvider provider)
47  {
48  return string.Empty;
49  }
50 
54  {
55  return TypeCode.DBNull;
56  }
57 
63  {
64  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
65  }
66 
71  char IConvertible.ToChar(IFormatProvider provider)
72  {
73  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
74  }
75 
80  sbyte IConvertible.ToSByte(IFormatProvider provider)
81  {
82  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
83  }
84 
89  byte IConvertible.ToByte(IFormatProvider provider)
90  {
91  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
92  }
93 
98  short IConvertible.ToInt16(IFormatProvider provider)
99  {
100  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
101  }
102 
107  ushort IConvertible.ToUInt16(IFormatProvider provider)
108  {
109  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
110  }
111 
116  int IConvertible.ToInt32(IFormatProvider provider)
117  {
118  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
119  }
120 
125  uint IConvertible.ToUInt32(IFormatProvider provider)
126  {
127  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
128  }
129 
134  long IConvertible.ToInt64(IFormatProvider provider)
135  {
136  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
137  }
138 
143  ulong IConvertible.ToUInt64(IFormatProvider provider)
144  {
145  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
146  }
147 
152  float IConvertible.ToSingle(IFormatProvider provider)
153  {
154  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
155  }
156 
161  double IConvertible.ToDouble(IFormatProvider provider)
162  {
163  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
164  }
165 
170  decimal IConvertible.ToDecimal(IFormatProvider provider)
171  {
172  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
173  }
174 
179  DateTime IConvertible.ToDateTime(IFormatProvider provider)
180  {
181  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
182  }
183 
191  object IConvertible.ToType(Type type, IFormatProvider provider)
192  {
193  return Convert.DefaultToType(this, type, provider);
194  }
195  }
196 }
bool ToBoolean(IFormatProvider provider)
Converts the value of this instance to an equivalent Boolean value using the specified culture-specif...
TypeCode
Specifies the type of an object.
Definition: TypeCode.cs:9
Definition: __Canon.cs:3
The exception that is thrown for invalid casting or explicit conversion.
Provides a mechanism for retrieving an object to control formatting.
Describes the source and destination of a given serialized stream, and provides an additional caller-...
A type representing a date and time value.
TypeCode GetTypeCode()
Gets the T:System.TypeCode value for T:System.DBNull.
Definition: DBNull.cs:53
void GetObjectData(SerializationInfo info, StreamingContext context)
Implements the T:System.Runtime.Serialization.ISerializable interface and returns the data needed to ...
Definition: DBNull.cs:30
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
A cast or conversion operation, such as (SampleType)obj in C::or CType(obj, SampleType) in Visual Bas...
override string ToString()
Returns an empty string (F:System.String.Empty).
Definition: DBNull.cs:37
static readonly DBNull Value
Represents the sole instance of the T:System.DBNull class.
Definition: DBNull.cs:13
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
Allows an object to control its own serialization and deserialization.
Definition: ISerializable.cs:8
Specifies that the class can be serialized.
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
Defines methods that convert the value of the implementing reference or value type to a common langua...
Definition: IConvertible.cs:9
string ToString(IFormatProvider provider)
Returns an empty string using the specified T:System.IFormatProvider.
Definition: DBNull.cs:46
Represents a nonexistent value. This class cannot be inherited.
Definition: DBNull.cs:10