Boolean.Parse 方法

定義

多載

名稱 Description
Parse(ReadOnlySpan<Char>)

將邏輯值的指定張幅表示轉換為其 Boolean 等價值。

Parse(String)

將指定的字串表示轉換為邏輯 Boolean 值的等價值。

Parse(ReadOnlySpan<Char>)

來源:
Boolean.cs
來源:
Boolean.cs
來源:
Boolean.cs
來源:
Boolean.cs
來源:
Boolean.cs

將邏輯值的指定張幅表示轉換為其 Boolean 等價值。

public:
 static bool Parse(ReadOnlySpan<char> value);
public static bool Parse(ReadOnlySpan<char> value);
static member Parse : ReadOnlySpan<char> -> bool
Public Shared Function Parse (value As ReadOnlySpan(Of Char)) As Boolean

參數

value
ReadOnlySpan<Char>

一個包含要轉換值字元的跨度。

傳回

truevalue 等價 TrueString於 ; falsevalue 等價於 FalseString

適用於

Parse(String)

來源:
Boolean.cs
來源:
Boolean.cs
來源:
Boolean.cs
來源:
Boolean.cs
來源:
Boolean.cs

將指定的字串表示轉換為邏輯 Boolean 值的等價值。

public:
 static bool Parse(System::String ^ value);
public static bool Parse(string value);
static member Parse : string -> bool
Public Shared Function Parse (value As String) As Boolean

參數

value
String

一個包含要轉換值的字串。

傳回

truevalue 等價 TrueString於 ; falsevalue 等價於 FalseString

例外狀況

valuenull

value 不等價於 TrueStringFalseString

範例

以下程式碼範例說明方法的 Parse 使用。

bool val;
string input;

input = bool.TrueString;
val = bool.Parse(input);
Console.WriteLine("'{0}' parsed as {1}", input, val);
// The example displays the following output:
//       'True' parsed as True
let input = bool.TrueString
let value = bool.Parse input
printfn $"'{input}' parsed as {value}"
// The example displays the following output:
//       'True' parsed as True
Dim val As Boolean
Dim input As String

input = Boolean.TrueString
val = Boolean.Parse(input)
Console.WriteLine("'{0}' parsed as {1}", input, val)
' The example displays the following output:
'       'True' parsed as True

備註

value參數前置或後方可加空白,必須包含其中之一TrueString;FalseString否則會拋出例外。 此比較不區分大小寫。

另請參閱

適用於