这是我之前的问题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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
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?
Run Code Online (Sandbox Code Playgroud)
这个错误意味着什么,我该如何解决?
Jes*_*cer 10
您需要在System.Numerics.dll中添加引用(右键单击"解决方案资源管理器"中的"引用"并选择"添加引用").
另外,放入using System.Numerics而不是让你的方法的命名空间(即将它命名为代码库更具描述性).
| 归档时间: |
|
| 查看次数: |
5687 次 |
| 最近记录: |