mscorlib.dll中发生了未处理的“System.FormatException”类型异常

时间:2011-06-16 11:13:20

标签: c# string biginteger bouncycastle

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)

这里有什么问题?

1 个答案:

答案 0 :(得分:3)

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

BigInteger P = new BigInteger(p,16); 
相关问题