Char.Parse(String) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將指定字串的值轉換為其相等的 Unicode 字元。
public:
static char Parse(System::String ^ s);
public static char Parse(string s);
static member Parse : string -> char
Public Shared Function Parse (s As String) As Char
參數
- s
- String
包含單一字元的字串,或 null。
傳回
一個與 中 s唯一字元等價的 Unicode 字元。
例外狀況
s 是 null。
長度 s 不是1。
範例
以下程式碼範例示範 Parse。
using System;
public class ParseSample {
public static void Main() {
Console.WriteLine(Char.Parse("A")); // Output: 'A'
}
}
open System
Char.Parse "A"
|> printfn "%c" // Output: 'A'
Module ParseSample
Sub Main()
Console.WriteLine(Char.Parse("A")) ' Output: 'A'
End Sub
End Module
適用於
另請參閱
- ToString()
解析 .NET