An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll

試著忘記壹切 提交于 2020-01-17 05:05:17

问题


using Org.BouncyCastle.Math;
    string p = "E7A69EBDF105F2A6BBDEAD7E798F76A209AD73FB466431E2E7352ED262F8C558F10BEFEA977DE9E21DCEE9B04D245F300ECCBBA03E72630556D011023F9E857F";
    BigInteger P= new BigInteger(p);

throwing Exception

System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffe
r& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo in
fo)
   at System.Int32.Parse(String s, NumberStyles style)
   at Org.BouncyCastle.Math.BigInteger..ctor(String str, Int32 radix)
   at Org.BouncyCastle.Math.BigInteger..ctor(String value)

what's wrong here?


回答1:


If your number string is in hexadecimal, you'll need to specify the radix in the constructor as:

BigInteger P = new BigInteger(p,16); 


来源:https://stackoverflow.com/questions/6370861/an-unhandled-exception-of-type-system-formatexception-occurred-in-mscorlib-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!