語言

Char.Parse(String) 方法

定義

將指定字串的值轉換為其相等的 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

適用於

另請參閱