I am writing a Console application that outputs the binary average of inputted base-10 numbers:
Console.WriteLine("Enter numbers to find the average of. Seperate each number with a pound sign(#)");
string[] n = Console.ReadLine().Split('#');
List<string> final = new List<string>();
final.AddRange(n);
double t = 0;
for (int i = 0; i < final.Count; i++)
{
t = t + Convert.ToDouble(final[i]);
}
int ct = final.Count;
double average = t / ct;
string binAv = Convert.ToString(average, 2);
However, the compiler generates a build-time error on the "Convert.ToString(average,2)" line. The error:
The best overloaded method match for 'System.Convert.ToString(double, System.IFormatProvider)' has some invalid arguments
How can I fix this error? Thanks.