我正在尝试将基数 2 转换为基数 10,但我不断收到:
"Value was either too large or too small for an Int64".
我使用此代码:
string number1 = Convert.ToString(Convert.ToInt64(numberBin1, 10));
即使使用合理的值,它也会显示错误,例如:000111110100111101010000
编辑:感谢 Johnny 和 JSteward 修复
最佳答案
ToInt64
方法的第二个参数是 fromBase
,在您的情况下它应该是 2。
long number = Convert.ToInt64("000111110100111101010000", 2));
关于c# - 将基数 2 转换为基数 10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54597842/