0x6*_*C74 2 c# windows console visual-studio
在这个例子的启发下,我决定扩展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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我使用过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?)
Run Code Online (Sandbox Code Playgroud)
好.我错过了一个装配参考.我想"它一定很简单.整个系统应该是两个System.Numerics.dll文件 - 我需要的是添加到命令/链接:[System.Numerics.dll的x86版本的路径]".搜索结果冻结了我的灵魂:
正如你所看到的(或不是),有比我预测的更多的文件!而且,它们的大小和内容不同.我应该包括哪一个?为什么有五个文件,虽然只有两个存在点?/ link:命令是否正确?或许我的思维轨迹完全错了?
我一般都发现使用
/r:System.Numerics.dll
Run Code Online (Sandbox Code Playgroud)
让编译器只在GAC中找到程序集,这通常是你想要的方式.(当然,前几天当我需要System.Numerics用于控制台应用程序时,它很好......)
| 归档时间: |
|
| 查看次数: |
950 次 |
| 最近记录: |