X hits on this document

832 views

0 shares

0 downloads

0 comments

279 / 396

C# LANGUAGE SPECIFICATION

int value; bool defined;

// Private instance constructor. Creates a DBInt with a known value.

DBInt(int value) { this.value = value; this.defined = true; }

// 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 // DBInt represents an unknown value.

public int Value { get { return value; } }

// Implicit conversion from int to DBInt.

public static implicit operator DBInt(int x) { return new DBInt(x); }

// Explicit conversion from DBInt to int. Throws an exception if the // given DBInt represents an unknown value.

public static explicit operator int(DBInt x) { if (!x.defined) throw new InvalidOperationException(); return x.value; }

public static DBInt operator +(DBInt x) { return x; }

public static DBInt operator -(DBInt x) { return x.defined ? -x.value : Null; }

public static DBInt operator +(DBInt x, DBInt y) { return x.defined && y.defined? x.value + y.value: Null; }

public static DBInt operator -(DBInt x, DBInt y) { return x.defined && y.defined? x.value - y.value: Null; }

public static DBInt operator *(DBInt x, DBInt y) { return x.defined && y.defined? x.value * y.value: Null; }

public static DBInt operator /(DBInt x, DBInt y) { return x.defined && y.defined? x.value / y.value: Null; }

public static DBInt operator %(DBInt x, DBInt y) { return x.defined && y.defined? x.value % y.value: Null; }

public static DBBool operator ==(DBInt x, DBInt y) { return x.defined && y.defined? x.value == y.value: DBBool.Null; }

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

Document info
Document views832
Page views832
Page last viewedSun Dec 04 14:46:49 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments