由于其保护级别,无法访问Mono.Math.BigInteger

编程入门 行业动态 更新时间:2024-10-25 17:20:49
本文介绍了由于其保护级别,无法访问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.BigInteger在Mono.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.

虽然BigInteger在mscorlib.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 提交错误.

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.

更多推荐

由于其保护级别,无法访问Mono.Math.BigInteger

本文发布于:2023-11-26 20:02:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634988.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:于其   无法访问   级别   BigInteger   Mono

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!