gpt4 book ai didi

c# - 如何修复 "The type or namespace name could not be found"?

转载 作者:太空狗 更新时间:2023-10-29 22:27:40 26 4
gpt4 key购买 nike

这是我之前问题的后续问题 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com