类型为';System.FormatException';发生在mscorlib.dll中

本文关键字:mscorlib dll FormatException System 类型 | 更新日期: 2023-09-27 17:59:13

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

抛出异常

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)

这里怎么了?

类型为';System.FormatException';发生在mscorlib.dll中

如果数字字符串是十六进制的,则需要在构造函数中指定基数为:

BigInteger P = new BigInteger(p,16);