The bool Type : Boolean Data Type : Data Type C# Examples


C# Examples » Data Type » Boolean Data Type »

 

The bool Type






The bool type represents true/false values.
C# defines the values true and false using the reserved words 'true' and 'false'.
A variable or expression of type bool will be one of these two values.
There is no conversion defined between bool and integer values.

The Boolean structure supports the bool data type.:




    
public  static  readonly  string  FalseString
            public  static  readonly  string  TrueString
    
   
  
   

These contain the human-readable forms of true and false.
Boolean implements the following interfaces:

IComparable and
IConvertible.

Methods Defined by Boolean



Method
Meaning


public int CompareTo(object v)
Returns zero if the values are equal. Returns a negative value if the invoking object is false and v is true. Returns a positive value if the invoking object is true and v is false.


public override bool Equals(object v)
Returns true if the value of the invoking object equals the value of v.


public override int GetHashCode()
Returns the hash code.


public TypeCode GetTypeCode()
Returns the TypeCode enumeration value for Boolean, which is TypeCode.Boolean.


public static bool Parse(string str)
Parses the string. If the string is neither "True" nor "False", an exception is thrown. However, case differences are ignored.


public override string ToString()
Convert to string.


string ToString(IFormatProvider fmtpvdr)
Convert to string using the culture-specific information specified in fmtpvdr.






HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Boolean Data Type