Boolean.ToString 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將此實例的值轉換為其等價的字串表示(可為「真」或「假」)。
多載
| 名稱 | Description |
|---|---|
| ToString(IFormatProvider) |
將此實例的值轉換為其等價的字串表示(可為「真」或「假」)。 |
| ToString() |
將此實例的值轉換為其等價的字串表示(可為「真」或「假」)。 |
ToString(IFormatProvider)
- 來源:
- Boolean.cs
- 來源:
- Boolean.cs
- 來源:
- Boolean.cs
- 來源:
- Boolean.cs
- 來源:
- Boolean.cs
將此實例的值轉換為其等價的字串表示(可為「真」或「假」)。
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」視為有效的布林值集合。 若該方法回傳StringToString(IFormatProvider)的物件要寫入 XML 檔案,應先呼叫其String.ToLowerInvariant方法將其轉換為小寫。
適用於
ToString()
- 來源:
- Boolean.cs
- 來源:
- Boolean.cs
- 來源:
- Boolean.cs
- 來源:
- Boolean.cs
- 來源:
- Boolean.cs
將此實例的值轉換為其等價的字串表示(可為「真」或「假」)。
public:
override System::String ^ ToString();
public override string ToString();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
傳回
若該實例的值為 ,則稱為「True」(TrueString屬性值),若該實例的值為 trueFalseString,則為「False」(性質的值false)。
範例
以下範例說明此 ToString 方法。
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 方法將其轉換為小寫。