System.Boolean Structure

public struct Boolean : IComparable, IComparable<Boolean>, IEquatable<Boolean>

Base Types

Object
  ValueType
    Boolean

This type implements IComparable, System.IComparable<System.Boolean>, and System.IEquatable<System.Boolean>.

Assembly

mscorlib

Library

BCL

Summary

Represents a Boolean value.

Description

The Boolean value type represents the logical values true and false . The size of this type is 8 bits, the representation of false is all-bits-zero, and the representation of true is unspecified except that it shall have at least one bit set.

See Also

System Namespace

Members

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

Boolean.FalseString Field
Boolean.TrueString Field


Boolean.CompareTo(bool) Method

public int CompareTo(bool value);

Summary

Returns the sort order of the current instance compared to the specified Boolean .

Parameters

value
A Boolean to compare to the current instance.

Return Value

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 ValueCondition
A negative numberCurrent instance is false and value is true .
ZeroCurrent instance == value .
Any positive numberCurrent instance is true and value is false .

Description

[Note: This method is implemented to support the System.IComparable<Boolean> interface.]

See Also

System.Boolean Structure, System Namespace

Boolean.CompareTo(System.Object) Method

public int CompareTo(object obj);

Summary

Returns the sort order of the current instance compared to the specified Object .

Parameters

obj
A Object to compare to the current instance.

Return Value

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 ValueCondition
A negative numberCurrent instance is false and obj is true .
ZeroCurrent instance == obj .
Any positive numberCurrent instance is true and obj is false , or obj is a null reference.

Exceptions

Exception TypeCondition
ArgumentExceptionobj is not a Boolean and is not a null reference.

Description

[Note: This method is implemented to support the IComparable interface.]

See Also

System.Boolean Structure, System Namespace

Boolean.Equals(bool) Method

public override bool Equals(bool obj);

Summary

Determines whether the current instance and the specified Boolean represent the same value.

Parameters

obj
The Boolean to compare to the current instance.

Return Value

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.]

See Also

System.Boolean Structure, System Namespace

Boolean.Equals(System.Object) Method

public override bool Equals(object obj);

Summary

Determines whether the current instance and the specified Object represent the same type and value.

Parameters

obj
The Object to compare to the current instance.

Return Value

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, returns false .

Description

[Note: This method overrides System.Object.Equals(System.Object).]

See Also

System.Boolean Structure, System Namespace

Boolean.GetHashCode Method

public override int GetHashCode();

Summary

Generates a hash code for the current instance.

Return Value

A Int32 value containing a hash code for the current instance.

Description

The algorithm used to generate the hash code is unspecified.

[Note: This method overrides System.Object.GetHashCode .]

See Also

System.Boolean Structure, System Namespace

Boolean.Parse Method

public static bool Parse(string value);

Summary

Returns the specified String converted to a Boolean value.

Parameters

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.

Return Value

true if value is equivalent to System.Boolean.TrueString; otherwise, false .

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue is not equivalent to either System.Boolean.TrueString or System.Boolean.FalseString.

Example

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".

See Also

System.Boolean Structure, System Namespace

Boolean.ToString(System.IFormatProvider) Method

public string ToString(IFormatProvider provider);

Summary

Converts the value of this instance to its equivalent String representation.

Parameters

provider
(Reserved) A IFormatProvider object.

Return Value

System.Boolean.TrueString if the value of this instance is true , or System.Boolean.FalseString if the value of this instance is false .

Description

The provider parameter is reserved. It does not participate in the execution of this method.

See Also

System.Boolean Structure, System Namespace

Boolean.ToString() Method

public override string ToString();

Summary

Returns a String representation of the value of the current instance.

Return Value

System.Boolean.FalseString if the value of the current instance is false ; otherwise, System.Boolean.TrueString.

Description

[Note: This method overrides System.Object.ToString .]

See Also

System.Boolean Structure, System Namespace

Boolean.FalseString Field

public static readonly string FalseString;

Summary

Contains a String representation of the logical value false .

Description

This field is read-only.

The value of this String is "False".

See Also

System.Boolean Structure, System Namespace

Boolean.TrueString Field

public static readonly string TrueString;

Summary

Contains a String representation of the logical value true .

Description

This field is read-only.

The value of this String is "True".

See Also

System.Boolean Structure, System Namespace