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

傳回

Char

Unicode 字元,相當於 s 中的唯一字元。

例外狀況

snull

s 的長度不是 1。

範例

下列程式碼範例將示範 Parse

using namespace System;
int main()
{
   Console::WriteLine( Char::Parse(  "A" ) ); // Output: 'A'
}
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

適用於

另請參閱