C# | Char.TryParse () Method Last Updated : 10 Feb, 2023 Comments Improve Suggest changes Like Article Like Report In C#, Char.TryParse() is Char class method which is used to convert the value from given string to its equivalent Unicode character. Its performance is better than Char.Parse() method. Syntax : public static bool TryParse(string str, out char result) Parameter: str: It is System.String type parameter which can contain single character or NULL.result: This is an uninitialized parameter which is used to store the Unicode character equivalent when the conversion succeeded, or an undefined value if the conversion failed. The type of this parameter is System.Char. Return Type: The method return True, if successfully converted the string, otherwise return False. So type of this method is System.Boolean. Note: When string is NULL or Length is equal to 1 then conversion failed. Example 1: Below is a program to demonstrates the use of Char.TryParse() Method . CSHARP // C# program to illustrate the // Char.TryParse () Method using System; class GFG { // Main Method static public void Main() { // Declaration of data type bool result; Char value; // Input Capital letter A result = Char.TryParse("A", out value); // Display boolean type result Console.WriteLine(result); Console.WriteLine(value.ToString()); // Input Capital letter Z result = Char.TryParse("Z", out value); // Display boolean type result Console.WriteLine(result); Console.WriteLine(value.ToString()); // Input Symbol letter result = Char.TryParse("$", out value); // Display boolean type result Console.WriteLine(result); Console.WriteLine(value.ToString()); // Input number result = Char.TryParse("100", out value); // Display boolean type result Console.WriteLine(result); Console.WriteLine(value.ToString()); // Input small letter z result = Char.TryParse("z", out value); // Display boolean type result Console.WriteLine(result); Console.WriteLine(value.ToString()); } } Output:True A True Z True $ False True z Example 2: Below is an program to demonstrates the use Char.TryParse() method where the input is not a single character and start with a symbol. CSHARP // C# program to illustrate the // Char.TryParse () Method using System; class GFG { // Main Method static public void Main() { // Declaration of data type bool result; Char value; // Input is String return false result = Char.TryParse("GeeksforGeeks", out value); // Display boolean type result Console.WriteLine(result); Console.WriteLine(value.ToString()); // Input letter start with symbol < result = Char.TryParse("<N", out value); // Display boolean type result Console.WriteLine(result); Console.WriteLine(value.ToString()); } } Output:False False Comment More infoAdvertise with us Next Article C# | Char.TryParse () Method J jit_t Follow Improve Article Tags : C# CSharp-method Similar Reads C# | Char.Parse(String) Method 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 3 min read C# | Boolean.TryParse() Method This method is used to convert the specified string representation of a logical value to its Boolean equivalent. It returns a value that indicates whether the conversion succeeded or failed. Syntax: public static bool TryParse (string value, out bool result); Parameters: value: It is a string contai 2 min read C# | ToCharArray() Method In C#, ToCharArray() is a string method. This method is used to copy the characters from a specified string in the current instance to a Unicode character array or the characters of a specified substring in the current instance to a Unicode character array. This method can be overloaded by changing 4 min read C# | Char.IsSeparator ( ) Method In C#, Char.IsSeparator() is a System.Char struct method which is used to check whether a Unicode character can be categorized as a separator character or not. This method can be overloaded by passing different type and number of arguments to it. Char.IsSeparator(Char) MethodChar.IsSeparator(String, 3 min read C# | TrimStart() and TrimEnd() Method Prerequisite: Trim() Method in C# In C#, TrimStart() & TrimEnd() are the string methods. TrimStart() method is used to remove the occurrences of a set of characters specified in an array from the starting of the current String object. TrimEnd() method is used to remove the occurrences of a set o 3 min read Like