由于其保护级别,无法访问Mono.Math.BigInteger [英] Mono.Math.BigInteger is inaccessible due to its protection level

查看:104
本文介绍了由于其保护级别,无法访问Mono.Math.BigInteger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在使用ideone使用C#编写程序,并且是第一次使用Mono.我正在尝试使用BigInteger类(Mono.Math.BigInteger),但我不断收到错误消息.这是我下面的代码.发生了什么事,我该如何解决?谢谢.

So I'm working on a program in C# using ideone and I'm working with Mono for the first time. I'm trying to use the BigInteger class (Mono.Math.BigInteger) but I keep getting errors. Here's me code below. What is going on and how do I fix it? Thanks.

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个警告

prog.cs(9,13): error 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[]' is inaccessible due to its protection level /usr/lib/mono/2.0/mscorlib.dll (Location of the symbol related to previous error) prog.cs(23,27): error 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' is inaccessible due to its protection level /usr/lib/mono/2.0/mscorlib.dll (Location of the symbol related to previous error) Compilation failed: 4 error(s), 0 warnings

推荐答案

Mono.Math.BigIntegerMono.Security.dll中,您确定要引用正确的程序集吗?您收到的编译错误提示您不是.

Mono.Math.BigInteger is in the Mono.Security.dll, are you sure you are referencing the right assembly? The compilation errors you are getting suggest you aren't.

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

While BigInteger is used (internally) inside mscorlib.dll, you can't reference it from there.

或者,还有4.0版 System.Numerics.BigInteger 您可以通过将using更改为System.Numerics并引用System.Numerics.dll来使用该实现,但至少在目前看来,它的效果不如Mono.Math那样优化.

Alternatively, there's the 4.0 System.Numerics.BigInteger implementation that you can use by changing your using to System.Numerics and referencing System.Numerics.dll, but it doesn't look as optimized as the Mono.Math one, at least for now.

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

Unfortunately, Ideone does not seem to allow customizing assembly references, which means that you won't be able to compile either solution at all. You can only file a bug with Ideone.com.

这篇关于由于其保护级别,无法访问Mono.Math.BigInteger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆