System.Boolean Structure

Assembly: Mscorlib.dll
Namespace: System
Summary
Represents a Boolean value.
C# Syntax:
[Serializable]
public struct Boolean : IComparable, IConvertible
Thread Safety
This type is safe for multithreaded operations.
Remarks
Instances of this type have values of either true or false.

This value type implements interfaces IConvertible and IComparable. Use the Convert class for conversions instead of this type's explicit interface member implementation of IConvertible.

See also:
System Namespace

System.Boolean Member List:

Public Fields
FalseString Represents the Boolean value false as a string. This field is read-only.
TrueString Represents the Boolean value true as a string. This field is read-only.
Public Methods
CompareTo Compares this instance to a specified object and returns an indication of their relative values.
Equals Overridden:
Returns a value indicating whether this instance is equal to a specified object.
GetHashCode Overridden:
Returns the hash code for this instance.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
GetTypeCode Returns the TypeCode for value type Boolean.
Parse Converts the specified string representation of a logical value to its Boolean equivalent.
ToString Overloaded:
ToString()

Overridden:
Converts the value of this instance to its equivalent string representation.
ToString Overloaded:
ToString(IFormatProvider provider)

Converts the value of this instance to its equivalent string representation.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Boolean Member Details

Field: FalseString
Summary
Represents the Boolean value false as a string. This field is read-only.
C# Syntax:
public static readonly string FalseString;
Remarks
This field is equal to the string "False".
See also:
String | Boolean.TrueString

Return to top


Field: TrueString
Summary
Represents the Boolean value true as a string. This field is read-only.
C# Syntax:
public static readonly string TrueString;
Remarks
This field is equal to the string "True".
See also:
String | Boolean.FalseString

Return to top


Method: CompareTo(
   object obj
)
Summary
Compares this instance to a specified object and returns an indication of their relative values.
C# Syntax:
public int CompareTo(
   object obj
);
Parameters:

obj

An object to compare to this instance, or null.

Return Value:
A signed integer that indicates the relative order of this instance and obj.

Return Value Condition
Less than zero This instance is false and is true .
Zero This instance and are equal (either both are true or both are false ).
Greater than zero This instance is true and obj is false. -or- obj is null.
Exceptions
Exception Type Condition
ArgumentException obj is not a Boolean or null.
Remarks
obj must be null or an instance of Boolean; otherwise, an exception is thrown.

This method is implemented to support the IComparable interface.

See also:
Boolean.Equals | Object

Return to top


Overridden Method: Equals(
   object obj
)
Summary
Returns a value indicating whether this instance is equal to a specified object.
C# Syntax:
public override bool Equals(
   object obj
);
Parameters:

obj

An object to compare to this instance.

Return Value:
true if obj is a Boolean and has the same value as this instance; otherwise, false.
Remarks
This method overrides Object.Equals.
See also:
Boolean.CompareTo | Object

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~Boolean();

For more information on members inherited from System.Object click on the link above.

Return to top


Overridden Method: GetHashCode()
Summary
Returns the hash code for this instance.
C# Syntax:
public override int GetHashCode();
Return Value:
A hash code for the current Boolean.
Remarks
The Boolean class implements true as the integer, one, and false as the integer, zero. However, a particular programming language might represent true and false with other values.
See also:
Object.GetHashCode

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetTypeCode()
Summary
Returns the TypeCode for value type Boolean.
C# Syntax:
public TypeCode GetTypeCode();
Return Value:
The enumerated constant, TypeCode.Boolean.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Parse(
   string value
)
Summary
Converts the specified string representation of a logical value to its Boolean equivalent.
C# Syntax:
public static bool Parse(
   string value
);
Parameters:

value

A string containing the value to convert.

Return Value:
true if value is equivalent to Boolean.TrueString; otherwise, false.
Exceptions
Exception Type Condition
ArgumentNullException value is null.
FormatException value is not equivalent to Boolean.TrueString or Boolean.FalseString.
Remarks
The value parameter , optionally preceded or trailed by white space, must contain either Boolean.TrueString or Boolean.FalseString; otherwise, an exception is thrown. The comparison is case-insensitive.
See also:
ArgumentNullException | FormatException | String | Boolean.TrueString | Boolean.FalseString

Return to top


Overloaded Method: ToString()
Summary
Converts the value of this instance to its equivalent string representation.
C# Syntax:
public override string ToString();
Return Value:
Boolean.TrueString if the value of this instance is true, or Boolean.FalseString if the value of this instance is false.

Return to top


Overloaded Method: ToString(
   IFormatProvider provider
)
Summary
Converts the value of this instance to its equivalent string representation.
C# Syntax:
public string ToString(
   IFormatProvider provider
);
Parameters:

provider

(Reserved) An IFormatProvider object.

Return Value:
Boolean.TrueString if the value of this instance is true, or Boolean.FalseString if the value of this instance is false.
Remarks
The provider parameter is reserved. It does not participate in the execution of this method.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.