第一种,使用for语句:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyConsoleApplication
{
class Program
{
static void Main(string[] args)
{
int[] score = { 1, 2, 3, 4, 5, 6, 7, 8 };
for (int i = 0; i < score.Length;i++ )
{
Console.WriteLine(score[i]);
}
Console.ReadLine();
}
}
}
第二种,使用while语句:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyConsoleApplication
{
class Program
{
static void Main(string[] args)
{
int i=0;
int[] score = { 1, 2, 3, 4, 5, 6, 7, 8 };
while( i<score.Length)
{
Console.WriteLine(score[i]);
i++;
}
Console.ReadLine();
}
}
}
第三种使用foreach语句:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyConsoleApplication
{
class Program
{
static void Main(string[] args)
{
int[] score = { 1, 2, 3, 4, 5, 6, 7, 8 };
foreach (int temp in score)
{
Console.WriteLine(temp);
Console.ReadLine();
}
}
}
}