X hits on this document

966 views

0 shares

0 downloads

0 comments

281 / 396

C# LANGUAGE SPECIFICATION

public bool IsNull { get { return value == 0; } }

public bool IsFalse { get { return value < 0; } }

public bool IsTrue { get { return value > 0; } }

// Implicit conversion from bool to DBBool. Maps true to DBBool.True and // false to DBBool.False.

public static implicit operator DBBool(bool x) { return x? True: False; }

// Explicit conversion from DBBool to bool. Throws an exception if the // given DBBool is Null, otherwise returns true or false.

public static explicit operator bool(DBBool x) { if (x.value == 0) throw new InvalidOperationException(); return x.value > 0; }

// Equality operator. Returns Null if either operand is Null, otherwise // returns True or False.

public static DBBool operator ==(DBBool x, DBBool y) { if (x.value == 0 || y.value == 0) return Null; return x.value == y.value? True: False; }

// Inequality operator. Returns Null if either operand is Null, otherwise // returns True or False.

public static DBBool operator !=(DBBool x, DBBool y) { if (x.value == 0 || y.value == 0) return Null; return x.value != y.value? True: False; }

// Logical negation operator. Returns True if the operand is False, Null // if the operand is Null, or False if the operand is True.

public static DBBool operator !(DBBool x) { return new DBBool(-x.value); }

// Logical AND operator. Returns False if either operand is False, // otherwise Null if either operand is Null, otherwise True.

public static DBBool operator &(DBBool x, DBBool y) { return new DBBool(x.value < y.value? x.value: y.value); }

// Logical OR operator. Returns True if either operand is True, otherwise // Null if either operand is Null, otherwise False.

public static DBBool operator |(DBBool x, DBBool y) { return new DBBool(x.value > y.value? x.value: y.value); }

// Definitely true operator. Returns true if the operand is True, false // otherwise.

public static bool operator true(DBBool x) { return x.value > 0; }

268Copyright Microsoft Corporation 1999-2003. All Rights Reserved.

Document info
Document views966
Page views966
Page last viewedThu Dec 08 16:43:56 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments