Boolean.ToString 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将此实例的值转换为其等效字符串表示形式(“True”或“False”)。
重载
| ToString(IFormatProvider) |
将此实例的值转换为其等效字符串表示形式(“True”或“False”)。 |
| ToString() |
将此实例的值转换为其等效字符串表示形式(“True”或“False”)。 |
ToString(IFormatProvider)
- Source:
- Boolean.cs
- Source:
- Boolean.cs
- Source:
- Boolean.cs
- Source:
- Boolean.cs
将此实例的值转换为其等效字符串表示形式(“True”或“False”)。
public:
virtual System::String ^ ToString(IFormatProvider ^ provider);
public 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 对象。
返回
如果此实例的值为 TrueString,则为 true,或者,如果此实例的值为 FalseString,则为 false。
实现
注解
参数 provider 是保留的。 它不参与此方法的执行。 这意味着该方法 Boolean.ToString(IFormatProvider) 与大多数具有 provider 参数的方法不同,不会反映区域性特定的设置。
此方法返回常量“True”或“False”。 请注意,XML 区分大小写,并且 XML 规范将“true”和“false”识别为有效的布尔值集。 String如果方法返回ToString(IFormatProvider)的对象要写入 XML 文件,应首先调用其 String.ToLowerInvariant 方法以将其转换为小写。
适用于
ToString()
- Source:
- Boolean.cs
- Source:
- Boolean.cs
- Source:
- Boolean.cs
- Source:
- Boolean.cs
将此实例的值转换为其等效字符串表示形式(“True”或“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 属性的值)。
示例
下面的示例演示 ToString 了 方法。
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
let raining = false
let busLate = true
printfn $"raining.ToString() returns {raining}"
printfn $"busLate.ToString() returns {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”。
请注意,XML 区分大小写,并且 XML 规范将“true”和“false”识别为有效的布尔值集。 如果方法返回 ToString() 的字符串要写入 XML 文件,则应首先调用其 String.ToLowerInvariant 方法以将其转换为小写。