2
受this启发示例我决定展开Factorial类。通过控制台界面访问编译器时包含库
using System;
using System.Numerics;
namespace Functions
{
public class Factorial
{
public static BigInteger CalcRecursively(int number)
{
if (number > 1)
return (BigInteger)number * CalcRecursively(number - 1);
if (number <= 1)
return 1;
return 0;
}
public static BigInteger Calc(int number)
{
BigInteger rValue=1;
for (int i = 0; i < number; i++)
{
rValue = rValue * (BigInteger)(number - i);
}
return rValue;
}
}
}
我已经使用了System.Numerics,默认情况下它没有包括在内。因此,命令csc /target:library /out:Functions.dll Factorial.cs DigitCounter.cs
输出:
Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
Copyright (C) Microsoft Corporation. All rights reserved.
Factorial.cs(2,14): error CS0234: The type or namespace name 'Numerics' does not
exist in the namespace 'System' (are you missing an assembly reference?)
DigitCounter.cs(2,14): error CS0234: The type or namespace name 'Numerics' does
not exist in the namespace 'System' (are you missing an assembly
reference?)
Factorial.cs(8,23): error CS0246: The type or namespace name 'BigInteger' could
not be found (are you missing a using directive or an assembly
reference?)
Factorial.cs(18,23): error CS0246: The type or namespace name 'BigInteger' could
not be found (are you missing a using directive or an assembly
reference?)
DigitCounter.cs(8,42): 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文件 - 我需要的是添加到命令/链接:[System.Numerics.dll的x86版本的路径]”。搜索结果冻结了我的灵魂:
正如你所看到的(或没有)有比我预测的更多的文件!而且,它们的大小和内容各不相同。我应该包括哪一个?为什么有五个文件,虽然只有两个文件存在?/link:命令是否正确?或者,也许我完全错了我的思路?
很奇怪,在csc的命令手册('csc /?')中甚至没有提到这样有用的命令。 – 0x6B6F77616C74 2012-08-06 15:23:26
@kowalt:是的。 '/ r'只是'/ reference'的简写形式。 – 2012-08-06 15:24:23
我的overshight。无论如何,感谢您以可访问的方式描述它。 – 0x6B6F77616C74 2012-08-06 15:31:19