public struct Boolean : IComparable, IComparable<Boolean>, IEquatable<Boolean>
Object
ValueType
BooleanThis type implements IComparable, System.IComparable<System.Boolean>, and System.IEquatable<System.Boolean>.
mscorlib
BCL
Represents a Boolean value.
The Boolean value type represents the logical valuestrue
andfalse
. The size of this type is 8 bits, the representation offalse
is all-bits-zero, and the representation oftrue
is unspecified except that it shall have at least one bit set.
System Namespace
Boolean Methods
Boolean.CompareTo(bool) Method
Boolean.CompareTo(System.Object) Method
Boolean.Equals(bool) Method
Boolean.Equals(System.Object) Method
Boolean.GetHashCode Method
Boolean.Parse Method
Boolean.ToString(System.IFormatProvider) Method
Boolean.ToString() Method
Boolean Fields
public int CompareTo(bool value);
Returns the sort order of the current instance compared to the specified Boolean .
- value
- A Boolean to compare to the current instance.
The return value is a negative number, zero, or a positive number reflecting the sort order of the current instance as compared to value. For non-zero return values, the exact value returned by this method is unspecified. The following table defines the return value:
Return Value Condition A negative number Current instance is false
and value istrue
.Zero Current instance == value . Any positive number Current instance is true
and value isfalse
.
[Note: This method is implemented to support the System.IComparable<Boolean> interface.]
System.Boolean Structure, System Namespace
public int CompareTo(object obj);
Returns the sort order of the current instance compared to the specified Object .
- obj
- A Object to compare to the current instance.
The return value is a negative number, zero, or a positive number reflecting the sort order of the current instance as compared to obj. For non-zero return values, the exact value returned by this method is unspecified. The following table defines the return value:
Return Value Condition A negative number Current instance is false
and obj istrue
.Zero Current instance == obj . Any positive number Current instance is true
and obj isfalse
, or obj is a null reference.
Exception Type Condition ArgumentException obj is not a Boolean and is not a null reference.
[Note: This method is implemented to support the IComparable interface.]
System.Boolean Structure, System Namespace
public override bool Equals(bool obj);
Determines whether the current instance and the specified Boolean represent the same value.
- obj
- The Boolean to compare to the current instance.
true
if obj has the same value as the current instance; otherwise,false
.[Note: This method is implemented to support the System.IEquatable<Boolean> interface.]
System.Boolean Structure, System Namespace
public override bool Equals(object obj);
Determines whether the current instance and the specified Object represent the same type and value.
- obj
- The Object to compare to the current instance.
true
if obj is a Boolean with the same value as the current instance. If obj is a null reference or is not an instance of Boolean, returnsfalse
.
[Note: This method overrides System.Object.Equals(System.Object).]
System.Boolean Structure, System Namespace
public override int GetHashCode();
Generates a hash code for the current instance.
A Int32 value containing a hash code for the current instance.
The algorithm used to generate the hash code is unspecified.[Note: This method overrides System.Object.GetHashCode .]
System.Boolean Structure, System Namespace
public static bool Parse(string value);
Returns the specified String converted to a Boolean value.
- value
- A String containing the value to convert. The string is equivalent to either System.Boolean.TrueString or System.Boolean.FalseString, can contain leading and/or trailing whitespace, and is parsed in a case-insensitive manner.
true
if value is equivalent to System.Boolean.TrueString; otherwise,false
.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value is not equivalent to either System.Boolean.TrueString or System.Boolean.FalseString.
The following example demonstrates the System.Boolean.Parse(System.String) method.
using System; public class BoolParse { public static void Main() { Boolean b = Boolean.Parse(" true "); Console.WriteLine("\" true \" parses to \"{0}\".", b); } }The output is
" true " parses to "True".
System.Boolean Structure, System Namespace
public string ToString(IFormatProvider provider);
Converts the value of this instance to its equivalentString
representation.
- provider
- (Reserved) A IFormatProvider object.
System.Boolean.TrueString if the value of this instance istrue
, or System.Boolean.FalseString if the value of this instance isfalse
.
The provider parameter is reserved. It does not participate in the execution of this method.
System.Boolean Structure, System Namespace
public override string ToString();
Returns a String representation of the value of the current instance.
System.Boolean.FalseString if the value of the current instance isfalse
; otherwise, System.Boolean.TrueString.
[Note: This method overrides System.Object.ToString .]
System.Boolean Structure, System Namespace
public static readonly string FalseString;
Contains a String representation of the logical valuefalse
.
This field is read-only.The value of this String is "False".
System.Boolean Structure, System Namespace
public static readonly string TrueString;
Contains a String representation of the logical valuetrue
.
This field is read-only.The value of this String is "True".
System.Boolean Structure, System Namespace