作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
这是我之前问题的后续问题 https://codereview.stackexchange.com/questions/12165/efficency-in-c/12169 ,我尽力使用 BigIntegers 代替 ulongs,但我一定做错了什么。我是 C# 的新手,我熟悉 Java。这是我最好的转化机会:
using System;
namespace System.Numerics{
public class Factorial{
public static void Main(){
String InString = Console.ReadLine();
BigInteger num = 0;
BigInteger factorial = 1;
try {
num = BigInteger.Parse(InString);
Console.WriteLine(num);
}
catch (FormatException) {
Console.WriteLine("Unable to convert the String into a BigInteger");
}
for (BigInteger forBlockvar = num; forBlockvar > 1; forBlockvar--){
factorial *= forBlockvar;
}
Console.WriteLine("The Factorial for the Given input is:");
Console.WriteLine(factorial);
}
}
}
我得到了以下错误:
prog.cs(11,18): error CS0246: The type or namespace name `BigInteger' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(13,18): error CS0246: The type or namespace name `BigInteger' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(26,22): error CS0246: The type or namespace name `BigInteger' could not be found. Are you missing a using directive or an assembly reference?
这个错误是什么意思,我该如何解决?
最佳答案
您需要添加对 System.Numerics.dll 的引用(在解决方案资源管理器中右键单击“引用”并选择“添加引用”)。
此外,放入 using System.Numerics
而不是让您的方法的 namespace 成为那样(即,将其命名为对您的代码库更具描述性的名称)。
关于c# - 如何修复 "The type or namespace name could not be found"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10850250/
我是一名优秀的程序员,十分优秀!