for foreach循环

//for循环
int[] nums = {1,2,3,4,5,6,8,7,9,10 };
for (int i = 0; i < nums.Length;i++ )
{
Console.WriteLine(nums[i]);

}
Console.ReadKey();

//foreach循环 

int[] nums = { 1, 2, 3, 4, 5, 6, 8, 7, 9, 10 };

foreach (var item in nums)
{
Console.WriteLine(item);
}
Console.ReadKey();

posted @ 2016-04-14 21:44  思维乐趣  阅读(157)  评论(0编辑  收藏  举报