这是我之前的问题https://codereview.stackexchange.com/questions/12165/efficency-in-c/12169的后续工作,我尽力使用BigIntegers代替ulong,但是我一定做错了。我是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 (即,将其命名为对您的代码库更具描述性)。

10-07 19:47