这是我到目前为止的代码:
string[] animals = { "cow", "pig", "dog", "cat", "mouse", "giraffe", "moose", "deer", "lion", "hippo" };
Console.WriteLine("{0,5}{1,8}", "animal", "index");
Console.ReadLine();
答案 0 :(得分:5)
for(int i = 0; i < animals.length();i++) //Go through the whole array
{
Console.WriteLine(animals[i] + " " + i); //Output the animal and the index
}
Console.ReadLine(); //Wait for user input.