The Char.Parse(String) method in C# is used to convert the value of the specified string to its equivalent Unicode character.
Syntax
Following is the syntax −
public static char Parse (string str);
Above, the string str is a string that contains a single character or null.
Example
Let us now see an example to implement the Char.Parse(String) method −
using System;
public class Demo {
public static void Main(){
string str ="a";
char res = Char.Parse(str);
Console.WriteLine("Value = "+str);
Console.WriteLine("Equivalent Unicode character = "+res);
}
}Output
This will produce the following output −
Value = a Equivalent Unicode character = a
Example
Let us now see another example −
using System;
public class Demo {
public static void Main(){
string str ="#";
char res = Char.Parse(str);
Console.WriteLine("Value = "+str);
Console.WriteLine("Equivalent Unicode character = "+res);
}
}Output
This will produce the following output −
Value = # Equivalent Unicode character = #