作者Action (雪...)
看板C_Sharp
标题Using foreach on Arrays
时间Mon Nov 18 19:31:19 2002
C# 的 foreach ... in 用起来很方便呢!
--
C# also provides the foreach statement. This statement provides
a simple, clean way to iterate through the elements of an array.
For example, the following code creates an array called numbers
and iterates through it with the foreach statement:
int[] numbers = {4, 5, 6, 1, 2, 3, -2, -1, 0};
foreach (int i in numbers)
{
System.Console.WriteLine(i);
}
--
※ 发信站: 批踢踢实业坊(ptt.csie.ntu.edu.tw)
◆ From: 218.184.81.80