I am a newbie c# user and ı am doing some practice with w3resource.com, it is the question: Write a C# Sharp program that takes a number as input and print its multiplication table: and this is my
Console.WriteLine("Enter a number : ");
int number = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < 10; i++)
{
Console.WriteLine("{0} * {1} = {3}", number, i, number * i);
}
and it says to me that the index must be greater than 0...
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
(I have translated it from Turkish to English)
You have index {3}
in the Console.WriteLine
method, but you have only 3 arguments. The argument list is zero-based.
Console.WriteLine("{0} * {1} = {3}", number, i, number * i);
It should be
Console.WriteLine("{0} * {1} = {2}", number, i, number * i);