遍历数组元素FOREACH语句

用FOREACH语句可以遍历数组中的所有元素。

using System;
namespace a
{
	class Program
	{
		public static void Main(string[] args)
		{
			string[] friendNames={"Robert Barwell","Mike Parry","Jeremy Beacock"};
			Console.WriteLine("Here are {0} of my friends:",friendNames.Length);
			foreach (string friendName in friendNames)
			{
				Console.WriteLine(friendName);
			}
			Console.ReadKey();
		}
	}
}
原文地址:https://www.cnblogs.com/bimgoo/p/2468979.html