我得到这个异常:
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
在这一行:
String value = "2";
uint? test = Convert.ToUInt32(value, 2);
最佳答案
那是因为你的第二个参数将基数设置为 2,而 2 不是二进制的有效数字。
来自 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.
关于c# - 格式异常 : Could not find any recognizable digits,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34059155/