Can someone elaborate on what’s wrong with my code?

I'm not looking for someone to solve this, but I am looking for someone to guide me in the right direction in order to help me better comprehend. The goal of this code was to display the index numbers of the elements as the output, as well as the values of the arrays. As you can see, my code does output the values of the arrays, but I am having trouble with simply getting the index number to appear. I have been referencing online for a while, and can't seem to find the answer. What initiative would I have to take to further figure this out? class Program { static void Main(string[] args) { string[] names = new string [5];

 names[0] = "Al Dente"; names[1] = "Anna Graham"; names[2] = "Earle Bird"; names[3] = "Ginger Rayle"; names[4] = "Iona Ford"; foreach (string i in names) { Console.WriteLine(i); **EDIT: I know I need more than just the "i" in the Console.WriteLine, I just don't understand how to format it. } } } 


by AHopefulCynic via /r/csharp

Leave a Reply