Using foreach on Arrays

看板C_Sharp (C#)作者 (雪...)時間21年前 (2002/11/18 19:27), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
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
文章代碼(AID): #zsCwhI8 (C_Sharp)
文章代碼(AID): #zsCwhI8 (C_Sharp)