I am learning C#. I know how to do this in C++ but i get an exception to this line of code :
v[i] = int.Parse(Console.ReadLine());
System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'
int[] v = new int[n];
for (int i = 1; i <= n; i++)
{
v[i] = int.Parse(Console.ReadLine());
}
I want to translate this from C++ to C#:
int v[1001], n;
cin>>n;
for (int i = 1; i <= n; i++)
{
cin>>v[i];
}
There is more code but i think it's irelevant for this problem.