1. 程式人生 > >C# bool true, false 操作符過載,用在 if, while等語句中

C# bool true, false 操作符過載,用在 if, while等語句中

    // Definitely true operator. Returns true if the operand is True, false
    // otherwise.
    public static bool operator true(DBBool x)
    {
        return x.value > 0;
    }
    // Definitely false operator. Returns true if the operand is False, false
    // otherwise.
    public static bool operator
false(DBBool x) { return x.value < 0; }