UInt32.Parse(String) Method in C# with Examples Last Updated : 12 Jun, 2019 Comments Improve Suggest changes Like Article Like Report UInt32.Parse(String) Method is used to convert the string representation of a number to its 32-bit unsigned integer equivalent. Syntax: public static uint Parse (string str); Here, str is a string containing a number to convert. The format of str will be [optional white space][optional sign]digits[optional white space]. The sign can be positive or negative. But negative sign can be used only with zero otherwise it will throw an OverflowException. Return Value: It is a 32-bit unsigned integer equivalent to the number contained in str. Exceptions: ArgumentNullException: If str is null. FormatException: If str is not in the correct format. OverflowException: If str represents a number less than MinValue or greater than MaxValue. Below programs illustrate the use of above-discussed method: Example 1: csharp // C# program to demonstrate // UInt32.Parse(String) Method using System; class GFG { // Main Method public static void Main() { // passing different values // to the method to check checkParse("4294967295"); checkParse("14244,784"); checkParse("-457589"); checkParse(" 784845"); } // Defining checkParse method public static void checkParse(string input) { try { // declaring UInt32 variable uint val; // getting parsed value val = UInt32.Parse(input); Console.WriteLine("'{0}' parsed as {1}", input, val); } catch (OverflowException) { Console.WriteLine("Can't Parsed '{0}'", input); } catch (FormatException) { Console.WriteLine("Can't Parsed '{0}'", input); } } } Output: '4294967295' parsed as 4294967295 Can't Parsed '14244, 784' Can't Parsed '-457589' ' 784845' parsed as 784845 Example 2: For ArgumentNullException csharp // C# program to demonstrate // UInt32.Parse(String) Method // for ArgumentNullException using System; class GFG { // Main Method public static void Main() { try { // passing null value as a input checkParse(null); } catch (ArgumentNullException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } catch (FormatException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } // Defining checkparse method public static void checkParse(string input) { // declaring UInt32 variable uint val; // getting parsed value val = UInt32.Parse(input); Console.WriteLine("'{0}' parsed as {1}", input, val); } } Output: Exception Thrown: System.ArgumentNullException Reference: https://docs.microsoft.com/en-us/dotnet/api/system.uint32.parse?view=netframework-4.7.2#System_UInt32_Parse_System_String_ Comment More infoAdvertise with us Next Article UInt32.Parse(String) Method in C# with Examples K Kirti_Mangal Follow Improve Article Tags : C# CSharp-method CSharp-UInt32-Struct Similar Reads UInt64.Parse(String) Method in C# with Examples UInt64.Parse(String) Method is used to convert the string representation of a number to its 64-bit unsigned integer equivalent. Syntax: public static ulong Parse (string str); Here, str is a string containing a number to convert. The format of str will be [optional white space][optional sign]digits[ 2 min read UInt16.Parse(String) Method in C# with Examples UInt16.Parse(String) Method is used to convert the string representation of a number to its 16-bit unsigned integer equivalent. Syntax: public static ushort Parse (string str); Here, str is a string containing a number to convert. The format of str will be [optional white space][optional sign]digits 2 min read UInt32.ToString Method in C# with Examples | Set - 2 UInt32.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 UInt32.ToString() Method in C# with Examples | Set - 1 UInt32.ToString Method is used to convert the numeric value of the current UInt32 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 3 min read UInt64.ToString Method in C# with Examples | Set - 2 UInt64.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 Like