Boolean.ToString Boolean.ToString Boolean.ToString Boolean.ToString Method

定义

将此实例的值转换为其等效字符串表示形式(“True”或“False”)。Converts the value of this instance to its equivalent string representation (either "True" or "False").

重载

ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider)

将此实例的值转换为其等效字符串表示形式(“True”或“False”)。Converts the value of this instance to its equivalent string representation (either "True" or "False").

ToString() ToString() ToString() ToString()

将此实例的值转换为其等效字符串表示形式(“True”或“False”)。Converts the value of this instance to its equivalent string representation (either "True" or "False").

ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider)

将此实例的值转换为其等效字符串表示形式(“True”或“False”)。Converts the value of this instance to its equivalent string representation (either "True" or "False").

public:
 virtual System::String ^ ToString(IFormatProvider ^ provider);
public string ToString (IFormatProvider provider);
override this.ToString : IFormatProvider -> string
Public Function ToString (provider As IFormatProvider) As String

参数

provider
IFormatProvider IFormatProvider IFormatProvider IFormatProvider

(保留)一个 IFormatProvider 对象。(Reserved) An IFormatProvider object.

返回

如果此实例的值为 TrueString,则为 true,或者,如果此实例的值为 FalseString,则为 falseTrueString if the value of this instance is true, or FalseString if the value of this instance is false.

实现

注解

参数provider是保留的。The provider parameter is reserved. 它不参与此方法的执行。It does not participate in the execution of this method. 这意味着Boolean.ToString(IFormatProvider) ,与大多数provider带参数的方法不同,方法不会反映特定于区域性的设置。This means that the Boolean.ToString(IFormatProvider) method, unlike most methods with a provider parameter, does not reflect culture-specific settings.

此方法返回常量 "True" 或 "False"。This method returns the constants "True" or "False". 请注意,XML 区分大小写,XML 规范将 "true" 和 "false" 识别为有效的布尔值集。Note that XML is case-sensitive, and that the XML specification recognizes "true" and "false" as the valid set of Boolean values. ToString(IFormatProvider)如果方法返回的String.ToLowerInvariant对象将写入 XML 文件,则应首先调用其方法将其转换为小写。 StringIf the String object returned by the ToString(IFormatProvider) method is to be written to an XML file, its String.ToLowerInvariant method should be called first to convert it to lowercase.

ToString() ToString() ToString() ToString()

将此实例的值转换为其等效字符串表示形式(“True”或“False”)。Converts the value of this instance to its equivalent string representation (either "True" or "False").

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

返回

如果此实例的值为 true,则为“True”(TrueString 属性的值);如果此实例的值为 false,则为“False”(FalseString 属性的值)。"True" (the value of the TrueString property) if the value of this instance is true, or "False" (the value of the FalseString property) if the value of this instance is false.

示例

下面的示例演示ToString方法。The following example illustrates the ToString method.

Boolean raining = false;
Boolean busLate = true;
Console::WriteLine(  "raining->ToString() returns {0}", raining.ToString() );
Console::WriteLine(  "busLate->ToString() returns {0}", busLate.ToString() );
// The example displays the following output:
//       raining.ToString() returns False
//       busLate.ToString() returns True
bool raining = false;
bool busLate = true;

Console.WriteLine("raining.ToString() returns {0}", raining);
Console.WriteLine("busLate.ToString() returns {0}", busLate);
// The example displays the following output:
//       raining.ToString() returns False
//       busLate.ToString() returns True
Dim raining As Boolean = False
Dim busLate As Boolean = True

Console.WriteLine("raining.ToString() returns {0}", raining)
Console.WriteLine("busLate.ToString() returns {0}", busLate)
' The example displays the following output:
'       raining.ToString() returns False
'       busLate.ToString() returns True

注解

此方法返回常量 "True" 或 "False"。This method returns the constants "True" or "False".

请注意,XML 区分大小写,XML 规范将 "true" 和 "false" 识别为有效的布尔值集。Note that XML is case-sensitive, and that the XML specification recognizes "true" and "false" as the valid set of Boolean values. 如果ToString()方法返回的字符串将写入 XML 文件,则应首先调用其String.ToLowerInvariant方法将其转换为小写。If the string returned by the ToString() method is to be written to an XML file, its String.ToLowerInvariant method should be called first to convert it to lowercase.

适用于