Char.Parse(String) Method

Definition

将指定字符串的值转换为它的等效 Unicode 字符。Converts the value of the specified string to its equivalent Unicode character.

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

Parameters

s
String

包含单个字符的字符串,或 nullA string that contains a single character, or null.

Returns

Char

一个等效于 s 中唯一字符的 Unicode 字符。A Unicode character equivalent to the sole character in s.

Exceptions

snulls is null.

s 的长度不是 1。The length of s is not 1.

Examples

下面的代码示例演示 ParseThe following code example demonstrates 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'
    }
}
Module ParseSample

    Sub Main()

        Console.WriteLine(Char.Parse("A")) ' Output: 'A'

    End Sub

End Module

Applies to

See also