This documentation is archived and is not being maintained.

Char.Parse Method

Converts the value of the specified string to its equivalent Unicode character.

[Visual Basic]
Public Shared Function Parse( _
   ByVal s As String _
) As Char
public static char Parse(
 string s
public: static __wchar_t Parse(
 String* s
public static function Parse(
   s : String
) : Char;


A string containing a single character or a null reference (Nothing in Visual Basic).

Return Value

A Unicode character equivalent to the sole character in s.


Exception Type Condition
ArgumentNullException s is a null reference (Nothing in Visual Basic).
FormatException The length of s is not 1.


[Visual Basic, C#, C++] The following sample demonstrates Parse.

[Visual Basic] 
imports System

Module ParseSample

    Sub Main()

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

    End Sub

End Module

using System;

public class ParseSample {
    public static void Main() {
        Console.WriteLine(Char.Parse("A")); // Output: 'A'

#using <mscorlib.dll>
using namespace System;

int main() {
   Console::WriteLine(Char::Parse("A")); // Output: 'A'

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

Char Structure | Char Members | System Namespace | ToString