I am writing a program to input and output a simple array.
But it gives me input string was not in the correct format on
I also tried
but same error.
C#:
static void Main(string[] args)
{
int[] arr = new int[10];
Console.WriteLine("Enter nmber of elements");
int n = int.Parse(Console.ReadLine());
Console.WriteLine("Enter the elements");
for (int i = 0; i < n; i++)
arr[i] = int.Parse(Console.ReadLine());
Console.WriteLine("The array is\n");
for (int j = 0; j < n; j++)
Console.WriteLine(arr[j] + "\n");
Console.ReadKey();
}
But it gives me input string was not in the correct format on
C#:
arr[i] = int.Parse(Console.ReadLine());
I also tried
C#:
arr[i] = Convert.ToInt32(Console.ReadLine());
Last edited: