C# | Char.ConvertToUtf32(String, Int32) Method Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report This method is used to converts the value of a UTF-16 encoded character or surrogate pair at a specified position in a string into a Unicode code point. Syntax: public static int ConvertToUtf32 (string s, int index); Parameters: s: A string that contains a character or surrogate pair. index: The index position of the character or surrogate pair in s. Return Value: This method returns the 21-bit Unicode code point represented by the character or surrogate pair at the position in the s parameter specified by the index parameter. Exceptions: ArgumentNullException: If s is null. ArgumentOutOfRangeException: if index is not a position within s. Argument Exception: If the index is not a position within s. ArgumentException: If the specified index position contains a surrogate pair, and either the first character in the pair is not a valid high surrogate or the second character in the pair is not a valid low surrogate. Below programs illustrate the use of Char.ConvertToUtf32(String, Int32) Method: Example 1: csharp // C# program to demonstrate // Char.ConvertToUtf32(String, Int32) // Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { try { // declaring and initializing int // variable with 21 bit unicode int utf = 0xF42; // getting the value // using ConvertFromUtf32() string value = Char.ConvertFromUtf32(utf); // getting unicode point // using ConvertToUtf32() method int val = Char.ConvertToUtf32(value, 0); // Display the value Console.WriteLine("value is 0x{0:X}", val); } catch (ArgumentOutOfRangeException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: value is 0xF42 Example 2: For ArgumentOutOfRangeException csharp // C# program to demonstrate // Char.ConvertToUtf32(String, Int32) // Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { try { // declaring and initializing int // variable with 21 bit unicode int utf = 0x42F; // getting the value // using ConvertFromUtf32() string value = Char.ConvertFromUtf32(utf); // getting unicode point // using ConvertToUtf32() method Console.WriteLine("index is not a position within s."); int val = Char.ConvertToUtf32(value, 0xDFFF); // Display the value Console.WriteLine("value is 0x{0:X}", val); } catch (ArgumentOutOfRangeException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: index is not a position within s. Exception Thrown: System.ArgumentOutOfRangeException Example 3: For ArgumentNullException csharp // C# program to demonstrate // Char.ConvertToUtf32(String, Int32) // Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { try { // declaring and initializing // int variablewith 21 bit // unicode int utf = 0x42F; // getting the value // using ConvertFromUtf32() string value = null; // getting unicode point // using ConvertToUtf32() method Console.WriteLine("string value is null"); int val = Char.ConvertToUtf32(value, 0); // Display the value Console.WriteLine("value is 0x{0:X}", val); } catch (ArgumentNullException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } catch (ArgumentOutOfRangeException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } catch (ArgumentException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: string value is null Exception Thrown: System.ArgumentNullException Reference: https://learn.microsoft.com/en-us/dotnet/api/system.char.converttoutf32?view=netframework-4.7.2#System_Char_ConvertToUtf32_System_String_System_Int32_ Comment More infoAdvertise with us Next Article C# | Convert.FromBase64String(String) Method R rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp-Char-Struct Similar Reads C# | Char.ConvertFromUtf32(Int32) Method This method is used to converts the specified Unicode code point into a UTF-16 encoded string.Syntax: public static string ConvertFromUtf32 (int utf32); Here, utf32 is a 21-bit Unicode code point.Return Value: This method returns a string consisting of one Char object or a surrogate pair of Char obj 2 min read C# | Convert.FromBase64String(String) Method This method is used to convert the specified string, which encodes binary data as base-64 digits, to an equivalent 8-bit unsigned integer array. Syntax: public static byte[] FromBase64String (string s); Here, s is the string to convert. Return Value: This method returns an array of 8-bit unsigned in 4 min read C# | Char.ToString() Method In C#, Char.ToString() is a System.Char struct method which is used to convert the value of this instance to its equivalent string representation. This method can be overloaded by passing different type of arguments to it. Char.ToString(IFormatProvider) Method Char.ToString(Char) Method Char.ToStrin 2 min read C# | Int32.ToString Method | Set - 2 Int32.ToString Method is used to convert the numeric value of the current instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows: ToString(IFormatProvider) Method ToString(String, IFormatProvider) Method ToString() Method ToString(String) 2 min read C# | Int32.ToString Method | Set - 1 Int32.ToString Method is used to converts the numeric value of the current Int32 instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows:Here, we will discuss the first two methods. ToString(IFormatProvider) Method This method is used to c 2 min read C# | Convert.ToBase64String() Method | Set-1 Convert.ToBase64String() Method is used to convert the value of an array of 8-bit unsigned integers to its equivalent string representation which is encoded with base-64 digits. There are 4 methods in the overload of this method which are as follows: ToBase64String(Byte[], Int32, Int32) Method ToBas 4 min read Like