我有一个数组和简单的循环:
static BigInteger[] dataSet = new BigInteger[] { 100913, 1009139, 10091401, 100914061, 1009140611, 10091406133, 100914061337, 1009140613399 };
foreach (BigInteger num in dataSet ) {
BigInteger[] Vector = new BigInteger[num];
for (BigInteger i = 1; i <= num; i++) {
Vector[i - 1] = i;
}
}
谁能解释为什么此代码返回
无法将类型'System.Numerics.BigInteger'隐式转换为'int'。存在显式转换(您是否缺少演员表?)
错误出现在这一行:
BigInteger[] Vector = new BigInteger[num];
一切都转换为BigInteger,我看不到可能的原因。
感谢您的帮助,
提前致谢,
num
是一个,BigInteger
但您正在使用它来初始化数组的大小:
BigInteger[] Vector = new BigInteger[num];
数组的索引器为int
,这意味着您可以创建的最大大小为int.MaxValue
(2,147,483,647)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句