sumityadav
New member
Hello all, I am learning C# programming, and last night I was writing code to find the sum of even numbers between 1 to n. here is my code:
While run the code, it shows an error, i do not understand it, can anyone please help me with this, taking some of the references from *** spammy link removed -- no actual code in the link pertinent to this question ***.
C#:
using System;
class Program
{
static void Main()
{
int[] numbers = { 1, 2, 8 };
Console.WriteLine("\nArray1: [{0}]", string.Join(", ", numbers));
var temp = numbers[0];
for (var i = 0; i < numbers.Length - 1; i++)
{
numbers[i] = numbers[i + 1];
}
numbers[numbers.Length - 1] = temp;
Console.WriteLine("\nAfter rotating array becomes: [{0}]", string.Join(", ", numbers));
Console.ReadLine();
}
}
While run the code, it shows an error, i do not understand it, can anyone please help me with this, taking some of the references from *** spammy link removed -- no actual code in the link pertinent to this question ***.
Last edited by a moderator: