VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-char-parsestring-method/

⇱ C# | Char.Parse(String) Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# | Char.Parse(String) Method

Last Updated : 11 Jul, 2025
This method is used to convert the value of the specified string to its equivalent Unicode character. Syntax:
public static char Parse (string s);
Here, s is a string that contains a single character, or null. Return Value: This method returns a Unicode character equivalent to the sole character in s. Exceptions:
ArgumentNullException: If s is null. FormatException: If the length of s is not 1.
Below programs illustrate the use of Char.Parse(String) Method: Example 1:
Output:
Unicode character of string 1 is 1
Unicode character of string a is a
Unicode character of string @ is @
Unicode character of string - is -
Example 2: For ArgumentNullException
Output:
Unicode character of string 1 is 1
Unicode character of string a is a
Unicode character of string @ is @
Unicode character of string - is -

s is null
Exception Thrown: System.ArgumentNullException
Example 3: For FormatException
Output:
Unicode character of string 1 is 1
Unicode character of string a is a
Unicode character of string @ is @
Unicode character of string - is -

The length of s is not 1.
Exception Thrown: System.FormatException
Reference:
Comment
Article Tags:

Explore