mscorlib(4.0.0.0) API with additions
System.Boolean Struct Reference

Represents a Boolean (true or false) value. More...

Inheritance diagram for System.Boolean:
[legend]
Collaboration diagram for System.Boolean:
[legend]

Public Member Functions

override int GetHashCode ()
 Returns the hash code for this instance. More...
 
override string ToString ()
 Converts the value of this instance to its equivalent string representation (either "True" or "False"). More...
 
string ToString (IFormatProvider provider)
 Converts the value of this instance to its equivalent string representation (either "True" or "False"). More...
 
override bool Equals (object obj)
 Returns a value indicating whether this instance is equal to a specified object. More...
 
bool Equals (bool obj)
 Returns a value indicating whether this instance is equal to a specified T:System.Boolean object. More...
 
int CompareTo (object obj)
 Compares this instance to a specified object and returns an integer that indicates their relationship to one another. More...
 
int CompareTo (bool value)
 Compares this instance to a specified T:System.Boolean object and returns an integer that indicates their relationship to one another. More...
 
TypeCode GetTypeCode ()
 Returns the type code for the T:System.Boolean value type. More...
 
bool IConvertible. ToBoolean (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToBoolean(System.IFormatProvider). More...
 
char IConvertible. ToChar (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
sbyte IConvertible. ToSByte (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToSByte(System.IFormatProvider). More...
 
byte IConvertible. ToByte (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToByte(System.IFormatProvider). More...
 
short IConvertible. ToInt16 (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToInt16(System.IFormatProvider). More...
 
ushort IConvertible. ToUInt16 (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToUInt16(System.IFormatProvider). More...
 
int IConvertible. ToInt32 (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToInt32(System.IFormatProvider). More...
 
uint IConvertible. ToUInt32 (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToUInt32(System.IFormatProvider). More...
 
long IConvertible. ToInt64 (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToInt64(System.IFormatProvider). More...
 
ulong IConvertible. ToUInt64 (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToUInt64(System.IFormatProvider). More...
 
float IConvertible. ToSingle (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToSingle(System.IFormatProvider).. More...
 
double IConvertible. ToDouble (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToDouble(System.IFormatProvider).. More...
 
decimal IConvertible. ToDecimal (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToDecimal(System.IFormatProvider).. More...
 
DateTime IConvertible. ToDateTime (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
object IConvertible. ToType (Type type, IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToType(System.Type,System.IFormatProvider). More...
 
- Public Member Functions inherited from System.IEquatable< bool >
bool Equals (T other)
 Indicates whether the current object is equal to another object of the same type. More...
 

Static Public Member Functions

static bool Parse (string value)
 Converts the specified string representation of a logical value to its T:System.Boolean equivalent. More...
 
static bool TryParse (string value, out bool result)
 Tries to convert the specified string representation of a logical value to its T:System.Boolean equivalent. A return value indicates whether the conversion succeeded or failed. More...
 

Public Attributes

internal const int True = 1
 
internal const int False = 0
 
internal const string TrueLiteral = "True"
 
internal const string FalseLiteral = "False"
 

Static Public Attributes

static readonly string TrueString = "True"
 Represents the Boolean value true as a string. This field is read-only. More...
 
static readonly string FalseString = "False"
 Represents the Boolean value false as a string. This field is read-only. More...
 

Detailed Description

Represents a Boolean (true or false) value.

Definition at line 10 of file Boolean.cs.

Member Function Documentation

◆ CompareTo() [1/2]

int System.Boolean.CompareTo ( object  obj)

Compares this instance to a specified object and returns an integer that indicates their relationship to one another.

Parameters
objAn object to compare to this instance, or null.
Returns
A signed integer that indicates the relative order of this instance and obj .Return Value Condition Less than zero This instance is false and obj is true. Zero This instance and obj 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
T:System.ArgumentExceptionobj is not a T:System.Boolean.

Definition at line 98 of file Boolean.cs.

◆ CompareTo() [2/2]

int System.Boolean.CompareTo ( bool  value)

Compares this instance to a specified T:System.Boolean object and returns an integer that indicates their relationship to one another.

Parameters
valueA T:System.Boolean object to compare to this instance.
Returns
A signed integer that indicates the relative values of this instance and value .Return Value Condition Less than zero This instance is false and value is true. Zero This instance and value are equal (either both are true or both are false). Greater than zero This instance is true and value is false.

Definition at line 123 of file Boolean.cs.

◆ Equals() [1/2]

override bool System.Boolean.Equals ( object  obj)

Returns a value indicating whether this instance is equal to a specified object.

Parameters
objAn object to compare to this instance.
Returns
true if obj is a T:System.Boolean and has the same value as this instance; otherwise, false.

Definition at line 72 of file Boolean.cs.

◆ Equals() [2/2]

bool System.Boolean.Equals ( bool  obj)

Returns a value indicating whether this instance is equal to a specified T:System.Boolean object.

Parameters
objA T:System.Boolean value to compare to this instance.
Returns
true if obj has the same value as this instance; otherwise, false.

Definition at line 87 of file Boolean.cs.

◆ GetHashCode()

override int System.Boolean.GetHashCode ( )

Returns the hash code for this instance.

Returns
A hash code for the current T:System.Boolean.

Definition at line 33 of file Boolean.cs.

◆ GetTypeCode()

TypeCode System.Boolean.GetTypeCode ( )

Returns the type code for the T:System.Boolean value type.

Returns
The enumerated constant F:System.TypeCode.Boolean.

Implements System.IConvertible.

Definition at line 213 of file Boolean.cs.

◆ Parse()

static bool System.Boolean.Parse ( string  value)
static

Converts the specified string representation of a logical value to its T:System.Boolean equivalent.

Parameters
valueA string containing the value to convert.
Returns
true if value is equivalent to F:System.Boolean.TrueString; false if value is equivalent to F:System.Boolean.FalseString.
Exceptions
T:System.ArgumentNullExceptionvalue is null.
T:System.FormatExceptionvalue is not equivalent to F:System.Boolean.TrueString or F:System.Boolean.FalseString.

Definition at line 145 of file Boolean.cs.

◆ ToBoolean()

bool IConvertible. System.Boolean.ToBoolean ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToBoolean(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
true or false.

Implements System.IConvertible.

Definition at line 223 of file Boolean.cs.

◆ ToByte()

byte IConvertible. System.Boolean.ToByte ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToByte(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
1 if the value of this instance is true; otherwise, 0.

Implements System.IConvertible.

Definition at line 251 of file Boolean.cs.

◆ ToChar()

char IConvertible. System.Boolean.ToChar ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerThis parameter is ignored.
Returns
This conversion is not supported. No value is returned.
Exceptions
T:System.InvalidCastExceptionYou attempt to convert a T:System.Boolean value to a T:System.Char value. This conversion is not supported.

Implements System.IConvertible.

Definition at line 233 of file Boolean.cs.

◆ ToDateTime()

DateTime IConvertible. System.Boolean.ToDateTime ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerThis parameter is ignored.
Returns
This conversion is not supported. No value is returned.
Exceptions
T:System.InvalidCastExceptionYou attempt to convert a T:System.Boolean value to a T:System.DateTime value. This conversion is not supported.

Implements System.IConvertible.

Definition at line 342 of file Boolean.cs.

◆ ToDecimal()

decimal IConvertible. System.Boolean.ToDecimal ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToDecimal(System.IFormatProvider)..

Parameters
providerThis parameter is ignored.
Returns
1 if this instance is true; otherwise, 0.

Implements System.IConvertible.

Definition at line 332 of file Boolean.cs.

◆ ToDouble()

double IConvertible. System.Boolean.ToDouble ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToDouble(System.IFormatProvider)..

Parameters
providerThis parameter is ignored.
Returns
1 if this instance is true; otherwise, 0.

Implements System.IConvertible.

Definition at line 323 of file Boolean.cs.

◆ ToInt16()

short IConvertible. System.Boolean.ToInt16 ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToInt16(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
1 if this instance is true; otherwise, 0.

Implements System.IConvertible.

Definition at line 260 of file Boolean.cs.

◆ ToInt32()

int IConvertible. System.Boolean.ToInt32 ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToInt32(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
1 if this instance is true; otherwise, 0.

Implements System.IConvertible.

Definition at line 278 of file Boolean.cs.

◆ ToInt64()

long IConvertible. System.Boolean.ToInt64 ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToInt64(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
1 if this instance is true; otherwise, 0.

Implements System.IConvertible.

Definition at line 296 of file Boolean.cs.

◆ ToSByte()

sbyte IConvertible. System.Boolean.ToSByte ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToSByte(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
1 if this instance is true; otherwise, 0.

Implements System.IConvertible.

Definition at line 242 of file Boolean.cs.

◆ ToSingle()

float IConvertible. System.Boolean.ToSingle ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToSingle(System.IFormatProvider)..

Parameters
providerThis parameter is ignored.
Returns
1 if this instance is true; otherwise, 0.

Implements System.IConvertible.

Definition at line 314 of file Boolean.cs.

◆ ToString() [1/2]

override string System.Boolean.ToString ( )

Converts the value of this instance to its equivalent string representation (either "True" or "False").

Returns
"True" (the value of the F:System.Boolean.TrueString property) if the value of this instance is true, or "False" (the value of the F:System.Boolean.FalseString property) if the value of this instance is false.

Definition at line 45 of file Boolean.cs.

◆ ToString() [2/2]

string System.Boolean.ToString ( IFormatProvider  provider)

Converts the value of this instance to its equivalent string representation (either "True" or "False").

Parameters
provider(Reserved) An T:System.IFormatProvider object.
Returns
F:System.Boolean.TrueString if the value of this instance is true, or F:System.Boolean.FalseString if the value of this instance is false.

Implements System.IConvertible.

Definition at line 58 of file Boolean.cs.

◆ ToType()

object IConvertible. System.Boolean.ToType ( Type  type,
IFormatProvider  provider 
)

For a description of this member, see M:System.IConvertible.ToType(System.Type,System.IFormatProvider).

Parameters
typeThe desired type.
providerAn T:System.IFormatProvider implementation that supplies culture-specific information about the format of the returned value.
Returns
An object of the specified type, with a value that is equivalent to the value of this Boolean object.
Exceptions
T:System.ArgumentNullExceptiontype is null.
T:System.InvalidCastExceptionThe requested type conversion is not supported.

Implements System.IConvertible.

Definition at line 355 of file Boolean.cs.

◆ ToUInt16()

ushort IConvertible. System.Boolean.ToUInt16 ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToUInt16(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
1 if this instance is true; otherwise, 0.

Implements System.IConvertible.

Definition at line 269 of file Boolean.cs.

◆ ToUInt32()

uint IConvertible. System.Boolean.ToUInt32 ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToUInt32(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
1 if this instance is true; otherwise, 0.

Implements System.IConvertible.

Definition at line 287 of file Boolean.cs.

◆ ToUInt64()

ulong IConvertible. System.Boolean.ToUInt64 ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToUInt64(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
1 if this instance is true; otherwise, 0.

Implements System.IConvertible.

Definition at line 305 of file Boolean.cs.

◆ TryParse()

static bool System.Boolean.TryParse ( string  value,
out bool  result 
)
static

Tries to convert the specified string representation of a logical value to its T:System.Boolean equivalent. A return value indicates whether the conversion succeeded or failed.

Parameters
valueA string containing the value to convert.
resultWhen this method returns, if the conversion succeeded, contains true if value is equal to F:System.Boolean.TrueString or false if value is equal to F:System.Boolean.FalseString. If the conversion failed, contains false. The conversion fails if value is null or is not equal to the value of either the F:System.Boolean.TrueString or F:System.Boolean.FalseString field.
Returns
true if value was converted successfully; otherwise, false.

Definition at line 165 of file Boolean.cs.

Member Data Documentation

◆ FalseString

readonly string System.Boolean.FalseString = "False"
static

Represents the Boolean value false as a string. This field is read-only.

Definition at line 28 of file Boolean.cs.

◆ TrueString

readonly string System.Boolean.TrueString = "True"
static

Represents the Boolean value true as a string. This field is read-only.

Definition at line 24 of file Boolean.cs.


The documentation for this struct was generated from the following file: