我正在使用 ideone 编写 C# 程序,这是我第一次使用 Mono。我正在尝试使用 BigInteger 类(Mono.Math.BigInteger),但我不断收到错误。下面是我的代码。这是怎么回事?我该如何解决?谢谢。
using System;
using Mono.Math;
public class TFIB
{
public static int Main()
{
const int FIB_SEQUENCE_SIZE = 300;
BigInteger[] FibonacciSequence = new BigInteger[FIB_SEQUENCE_SIZE];
// Calculate Fibonacci Sequence
FibonacciSequence[0] = 0;
FibonacciSequence[1] = 1;
for (int i = 2; i < FIB_SEQUENCE_SIZE; i++)
{
FibonacciSequence[i] = FibonacciSequence[i - 1] + FibonacciSequence[i - 2];
}
while (true)
{
string[] tokenInput = Console.ReadLine().Split(' ');
Mono.Math.BigInteger lowerBound = Mono.Math.BigInteger.Parse(tokenInput[0]);
BigInteger upperBound = BigInteger.Parse(tokenInput[1]);
if (lowerBound == 0 && upperBound == 0)
{
break; // ending sequence found
}
else
{
// find the number of fibonacci sequences
int numbersInRange = 0;
for (int i = 0; i < FIB_SEQUENCE_SIZE; i++)
{
if (FibonacciSequence[i] >= lowerBound)
{
if (FibonacciSequence[i] <= upperBound)
{
numbersInRange++;
}
else
{
continue; // there is nothing more to find
}
}
}
Console.WriteLine(numbersInRange);
}
}
return 0;
}
}
这些是我收到的错误:
prog.cs(9,13): 错误 CS0122:Mono.Math.BigInteger' is inaccessible due to its protection level
/usr/lib/mono/2.0/mscorlib.dll (Location of the symbol related to previous error)
prog.cs(9,23): error CS0122:
Mono.Math.BigInteger[]' 由于其保护级别而无法访问
/usr/lib/mono/2.0/mscorlib.dll(与先前错误相关的符号的位置)
prog.cs(23,27):错误CS0122:Mono.Math.BigInteger' is inaccessible due to its protection level
/usr/lib/mono/2.0/mscorlib.dll (Location of the symbol related to previous error)
prog.cs(24,17): error CS0122:
Mono.Math.BigInteger' 由于其保护级别而无法访问
/usr/lib/mono/2.0/mscorlib.dll(与先前错误相关的符号的位置)
编译失败:4 个错误,0 个警告
Mono.Math.BigInteger
在里面Mono.Security.dll
,您确定引用的是正确的程序集吗?您收到的编译错误表明您没有。
While BigInteger
在内部(内部)使用mscorlib.dll
,您无法从那里引用它。
或者,还有 4.0System.Numerics.BigInteger http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx您可以通过更改您的实现来使用using
to System.Numerics
和参考System.Numerics.dll
,但它看起来并不像Mono.Math
一,至少目前是这样。
不幸的是,Ideone 似乎不允许自定义程序集引用,这意味着您根本无法编译任一解决方案。您只能使用以下方式提交错误Ideone.com http://ideone.com/.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)