Database integer type
The DBInt struct below implements an integer type that can represent the complete set of values of the int type, plus an additional state that indicates an unknown value. A type with these characteristics is commonly used in databases. using System; public struct DBInt public static readonly DBInt Null = new DBInt(); // When the defined field is true, this DBInt represents a known value int value; // Private instance constructor. Creates a DBInt with a known value. DBInt(int value) { // The IsNull property is true if this DBInt represents an unknown value. public bool IsNull { get { return!defined; } } // The Value property is the known value of this DBInt, or 0 if this public int Value { get { return value; } } // Implicit conversion from int to DBInt. public static implicit operator DBInt(int x) { // Explicit conversion from DBInt to int. Throws an exception if the public static explicit operator int(DBInt x) { public static DBInt operator +(DBInt x) { public static DBInt operator -(DBInt x) { public static DBInt operator +(DBInt x, DBInt y) { public static DBInt operator -(DBInt x, DBInt y) { public static DBInt operator *(DBInt x, DBInt y) { public static DBInt operator /(DBInt x, DBInt y) { public static DBInt operator %(DBInt x, DBInt y) { public static DBBool operator ==(DBInt x, DBInt y) { public static DBBool operator!=(DBInt x, DBInt y) { public static DBBool operator >(DBInt x, DBInt y) { public static DBBool operator <(DBInt x, DBInt y) { public static DBBool operator >=(DBInt x, DBInt y) { public static DBBool operator <=(DBInt x, DBInt y) { public override bool Equals(object obj) { public override int GetHashCode() { public override string ToString() {
|