遍历数组元素FOREACH语句
2012-04-24 22:16 精诚所至 金石为开 阅读(358) 评论(0) 编辑 收藏 举报用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://img2024.cnblogs.com/blog/35695/202408/35695-20240803130933255-1404888097.jpg)