Movatterモバイル変換


[0]ホーム

URL:


Skip to main contentSkip to in-page navigation

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

Boolean Struct

Definition

Namespace:
System
Assemblies:
mscorlib.dll, System.Runtime.dll
Assemblies:
netstandard.dll, System.Runtime.dll
Assembly:
System.Runtime.dll
Assembly:
mscorlib.dll
Assembly:
netstandard.dll
Source:
Boolean.cs
Source:
Boolean.cs
Source:
Boolean.cs
Source:
Boolean.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Represents a Boolean (true orfalse) value.

public value class bool : IComparable, IComparable<bool>, IConvertible, IEquatable<bool>
public value class bool : IComparable, IComparable<bool>, IConvertible, IEquatable<bool>, IParsable<bool>, ISpanParsable<bool>
public value class bool : IComparable, IConvertible
public value class bool : IComparable, IComparable<bool>, IEquatable<bool>
public struct Boolean : IComparable, IComparable<bool>, IConvertible, IEquatable<bool>
public readonly struct Boolean : IComparable, IComparable<bool>, IConvertible, IEquatable<bool>, IParsable<bool>, ISpanParsable<bool>
public readonly struct Boolean : IComparable, IComparable<bool>, IConvertible, IEquatable<bool>
[System.Serializable]public struct Boolean : IComparable, IConvertible
[System.Serializable][System.Runtime.InteropServices.ComVisible(true)]public struct Boolean : IComparable, IComparable<bool>, IConvertible, IEquatable<bool>
public struct Boolean : IComparable, IComparable<bool>, IEquatable<bool>
type bool = struct    interface IConvertible
type bool = struct    interface IConvertible    interface IParsable<bool>    interface ISpanParsable<bool>
[<System.Serializable>]type bool = struct    interface IConvertible
[<System.Serializable>][<System.Runtime.InteropServices.ComVisible(true)>]type bool = struct    interface IConvertible
type bool = struct
Public Structure BooleanImplements IComparable, IComparable(Of Boolean), IConvertible, IEquatable(Of Boolean)
Public Structure BooleanImplements IComparable, IComparable(Of Boolean), IConvertible, IEquatable(Of Boolean), IParsable(Of Boolean), ISpanParsable(Of Boolean)
Public Structure BooleanImplements IComparable, IConvertible
Public Structure BooleanImplements IComparable, IComparable(Of Boolean), IEquatable(Of Boolean)
Inheritance
Attributes
Implements

Remarks

For more information about this API, seeSupplemental API remarks for Boolean.

Fields

NameDescription
FalseString

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

TrueString

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

Methods

NameDescription
CompareTo(Boolean)

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

CompareTo(Object)

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

Equals(Boolean)

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

Equals(Object)

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

GetHashCode()

Returns the hash code for this instance.

GetTypeCode()

Returns the type code for theBoolean value type.

Parse(ReadOnlySpan<Char>)

Converts the specified span representation of a logical value to itsBoolean equivalent.

Parse(String)

Converts the specified string representation of a logical value to itsBoolean equivalent.

ToString()

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

ToString(IFormatProvider)

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

TryFormat(Span<Char>, Int32)

Tries to format the value of the current boolean instance into the provided span of characters.

TryParse(ReadOnlySpan<Char>, Boolean)

Tries to convert the specified span representation of a logical value to itsBoolean equivalent.

TryParse(String, Boolean)

Tries to convert the specified string representation of a logical value to itsBoolean equivalent.

Explicit Interface Implementations

NameDescription
IComparable.CompareTo(Object)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

IConvertible.GetTypeCode()

Returns theTypeCode for this instance.

IConvertible.ToBoolean(IFormatProvider)

For a description of this member, seeToBoolean(IFormatProvider).

IConvertible.ToByte(IFormatProvider)

For a description of this member, seeToByte(IFormatProvider).

IConvertible.ToChar(IFormatProvider)

This conversion is not supported. Attempting to use this method throws anInvalidCastException.

IConvertible.ToDateTime(IFormatProvider)

This conversion is not supported. Attempting to use this method throws anInvalidCastException.

IConvertible.ToDecimal(IFormatProvider)

For a description of this member, seeToDecimal(IFormatProvider).

IConvertible.ToDouble(IFormatProvider)

For a description of this member, seeToDouble(IFormatProvider).

IConvertible.ToInt16(IFormatProvider)

For a description of this member, seeToInt16(IFormatProvider).

IConvertible.ToInt32(IFormatProvider)

For a description of this member, seeToInt32(IFormatProvider).

IConvertible.ToInt64(IFormatProvider)

For a description of this member, seeToInt64(IFormatProvider).

IConvertible.ToSByte(IFormatProvider)

For a description of this member, seeToSByte(IFormatProvider).

IConvertible.ToSingle(IFormatProvider)

For a description of this member, seeToSingle(IFormatProvider).

IConvertible.ToString(IFormatProvider)

Converts the value of this instance to an equivalent string using the specified culture-specific formatting information.

IConvertible.ToType(Type, IFormatProvider)

For a description of this member, seeToType(Type, IFormatProvider).

IConvertible.ToUInt16(IFormatProvider)

For a description of this member, seeToUInt16(IFormatProvider).

IConvertible.ToUInt32(IFormatProvider)

For a description of this member, seeToUInt32(IFormatProvider).

IConvertible.ToUInt64(IFormatProvider)

For a description of this member, seeToUInt64(IFormatProvider).

IParsable<Boolean>.Parse(String, IFormatProvider)

Parses a string into a value.

IParsable<Boolean>.TryParse(String, IFormatProvider, Boolean)
ISpanParsable<Boolean>.Parse(ReadOnlySpan<Char>, IFormatProvider)

Parses a span of characters into a value.

ISpanParsable<Boolean>.TryParse(ReadOnlySpan<Char>, IFormatProvider, Boolean)

Applies to

Thread Safety

All members of this type are thread safe. Members that appear to modify instance state actually return a new instance initialized with the new value. As with any other type, reading and writing to a shared variable that contains an instance of this type must be protected by a lock to guarantee thread safety.

Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, seeour contributor guide.

Feedback

Was this page helpful?

YesNoNo

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?

In this article

Was this page helpful?

YesNo
NoNeed help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?