public struct Boolean : IComparable
Object
ValueType
BooleanThis type implements IComparable.
mscorlib
BCL
Represents a Boolean value.
The Boolean value type represents the logical valuestrue
andfalse
.
System Namespace
Boolean Methods
Boolean.CompareTo Method
Boolean.Equals Method
Boolean.GetHashCode Method
Boolean.Parse Method
Boolean.ToString(System.IFormatProvider) Method
Boolean.ToString() Method
Boolean Fields
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.
A Int32 containing a value that reflects the sort order of the current instance as compared to obj . The following table defines the conditions under which the returned value is a negative number, zero, or a positive number.
Return Value Condition Any 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(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