c# - Mono.Math.BigInteger 由于其保护级别而无法访问

标签 c# mono biginteger

所以我正在使用 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' 由于其保护级别而无法访问 /usr/lib/mono/2.0/mscorlib.dll(与先前错误相关的符号位置) prog.cs(9,23):错误 CS0122:Mono.Math.BigInteger[]' 由于其保护级别而无法访问 /usr/lib/mono/2.0/mscorlib.dll(与先前错误相关的符号位置) prog.cs(23,27):错误 CS0122:Mono.Math.BigInteger' 由于其保护级别而无法访问 /usr/lib/mono/2.0/mscorlib.dll(与先前错误相关的符号位置) prog.cs(24,17):错误 CS0122:Mono.Math.BigInteger' 由于其保护级别而无法访问 /usr/lib/mono/2.0/mscorlib.dll(与先前错误相关的符号位置) 编译失败:4 个错误,0 个警告

最佳答案

Mono.Math.BigInteger 位于 Mono.Security.dll 中,您确定引用了正确的程序集吗?您得到的编译错误表明您不是。

虽然 BigIntegermscorlib.dll 中(内部)使用,但您不能从那里引用它。

或者,还有 4.0 System.Numerics.BigInteger您可以通过将 using 更改为 System.Numerics 并引用 System.Numerics.dll 来使用该实现,但它看起来没有优化作为 Mono.Math,至少现在是这样。

不幸的是,Ideone 似乎不允许自定义程序集引用,这意味着您根本无法编译任何一种解决方案。您只能使用 Ideone.com 提交错误.

关于c# - Mono.Math.BigInteger 由于其保护级别而无法访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7632692/

相关文章:

c# - 可视化树外的数据绑定(bind)。数据上下文桥接

c# - .NET HEX颜色对于HTML来说太长

c# - 跨不同系统使用 Azure Service Fabric Reliable Actors

c# - Ubuntu 上单声道的 log4net Udp appender 不记录

java - 为什么这个 BigInteger 在输入 FFFFFFFF (8 F) 时显示不正确的结果

c# - Json.net DeserializeAnonymousType 返回 BigInteger 而不是 UInt64

java - BigInteger 除法() 方法不起作用?

c# - 从数据表中删除第一列

c# - 在 Linux 上使用 C#/Mono 处理外部媒体

ios - monotouch 上 system.net.sockets 的空引用