System.Boolean Structure

public struct Boolean : IComparable

Base Types

Object
  ValueType
    Boolean

This type implements IComparable.

Assembly

mscorlib

Library

BCL

Summary

Represents a Boolean value.

Description

The Boolean value type represents the logical values true and false .

See Also

System Namespace

Members

Boolean Methods

Boolean.CompareTo Method
Boolean.Equals 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 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

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 ValueCondition
Any 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 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