New to Learn C# Programming

sumityadav

New member
Joined
Apr 1, 2023
Messages
1
Location
India
Programming Experience
Beginner
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:

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:
I think the OP was hoping that someone would just re write the code that has nothing to do with summing even numbers to actually do it.

Edit after: After following the link provided by the OP this looks to be more of a sophisticated spam post rather than a true programming question because the link was about popular C# interview questions, but the questions are actually more about C# concepts and facts (and the page has some facts wrong) rather than C# programming interview questions. Looks to be a away to drive up page views so that the claim on that page that it is "one of the most visited" sites eventually becomes true.
 
Last edited:
Hello, this is Gulshan Negi.
Well, in my opinion, there is no issue with your code; even I executed it, and it is working fine. If there is some issue, then please mention it in detail.
Thanks
 
Back
Top Bottom