C# UInt32 Parse(String)
Description
UInt32 Parse(String)
converts the string representation
of a number to its 32-bit unsigned integer equivalent.
Syntax
UInt32.Parse(String)
has the following syntax.
[CLSCompliantAttribute(false)]
public static uint Parse(
string s
)
Parameters
UInt32.Parse(String)
has the following parameters.
s
- A string representing the number to convert.
Returns
UInt32.Parse(String)
method returns A 32-bit unsigned integer equivalent to the number contained in s.
Example
The following example uses the Parse(String) method to parse an array of string values.
/*w ww .jav a 2s. co m*/
using System;
public class MainClass{
public static void Main(String[] argv){
string[] values = { "+12340", "-0", "1,234,234", "$234,234,234,234",
"0xFA1B", "234234", "-10", "12342342342",
"16e07", "123423.0", "-12344" };
foreach (string value in values)
{
try {
uint number = UInt32.Parse(value);
Console.WriteLine("{0} --> {1}", value, number);
}
catch (FormatException) {
Console.WriteLine("{0}: Bad Format", value);
}
catch (OverflowException) {
Console.WriteLine("{0}: Overflow", value);
}
}
}
}
The code above generates the following result.