I get this exception:
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
At this line:
String value = "2";
uint? test = Convert.ToUInt32(value, 2);
That's because your second parameter sets the base to 2, and 2 is not a valid digit in binary.
From MSDN
The call to
public static uint ToUInt32(string value, int fromBase)
will throw aFormatException
whenvalue
contains a character that is not a valid digit in the base specified byfromBase
. The exception message indicates that there are no digits to convert if the first character in value is invalid; otherwise, the message indicates that value contains invalid trailing characters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With