Reputation: 730
This is a followup to my earlier question https://codereview.stackexchange.com/questions/12165/efficency-in-c/12169, and I tried my best to use BigIntegers in place of the ulongs, but I must have done something wrong. I am new to C#, and I am familiar with Java. This was my best shot at conversion:
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);
}
}
}
And I got the following errors:
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?
What does this error mean and how do I fix it?
Upvotes: 7
Views: 9778
Reputation: 5694
I had to add assembly references:
C:\My-Folder\My-Project-Name.ViewModel\bin\Debug\My-Project-Name.ViewModel.dll
Simply type the namespace on a new line in the textfield.
Upvotes: 0
Reputation: 20157
You need to add a reference (right-click on References in the Solution Explorer and select Add Reference) to System.Numerics.dll.
Also, put in using System.Numerics
rather than having your method's namespace be that (i.e. name it something more descriptive for your codebase).
Upvotes: 11