作者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