Inspiried by this example I decided to expand the Factorial class.
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;
}
}
}
I’ve used System.Numerics, which isn’t included by default. Therefore, the command
csc /target:library /out:Functions.dll Factorial.cs DigitCounter.cs outputs:
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?)
OK. I’am missing an assembly reference. I thought “It must be simple. On the whole system should be two System.Numerics.dll files – what I need is to add to the command /link:[Path to the x86 version of System.Numerics.dll] “. The searching results has frozen my soul:
As you can see(or not) there are many more files than I predicted! Moreover, they differ by the size and content. Which one should I include? Why there are five files, although only two have the point of existence? Is the /link:command correct? Or maybe am I totally wrong with my thinking track?
I’ve generally found that using
lets the compiler just find the assembly in the GAC, which is generally the way you want it. (Certainly it was fine the other day when I needed exactly System.Numerics for a console app…)