⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c6-06.cs

📁 一本很好的教材.C#开发者必备.内容全面,很难得哦.
💻 CS
字号:
public struct DBBool
{
   public static readonly DBBool Null = new DBBool(0);
   public static readonly DBBool False = new DBBool(-1);
   public static readonly DBBool True = new DBBool(1);
   DBBool(int value) {
      this.value = (sbyte)value;
   }
   public bool IsNull { get { return value == 0; } }
   public bool IsFalse { get { return value < 0; } }
   public bool IsTrue { get { return value > 0; } }
   public static implicit operator DBBool(bool x) {
      return x? True: False;
   }
   public static explicit operator bool(DBBool x) {
      if (x.value == 0) throw new InvalidOperationException();
      return x.value > 0;
   }
   public static DBBool operator ==(DBBool x, DBBool y) {
      if (x.value == 0 || y.value == 0) return Null;
      return x.value == y.value? True: 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;
   }
   public static DBBool operator !(DBBool x) {
      return new DBBool(-x.value);
   }
   public static DBBool operator &(DBBool x, DBBool y) {
      return new DBBool(x.value < y.value? x.value: y.value);
   }
   public static DBBool operator |(DBBool x, DBBool y) {
      return new DBBool(x.value > y.value? x.value: y.value);
   }
   public static bool operator true(DBBool x) {
      return x.value > 0;
   }
   public static bool operator false(DBBool x) {
      return x.value < 0;
   }
   public override bool Equals(object o) {
      try {
         return (bool) (this == (DBBool) o);
      }
      catch {
         return false;
      }
   }
   public override int GetHashCode() {
      return value;
   }
   public override string ToString() {
      switch (value) {
         case -1:
            return "DBBool.False";
         case 0:
            return "DBBool.Null";
         case 1:
            return "DBBool.True";
         default:
            throw new InvalidOperationException();
      }
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -