[C#] foreach


[C#] foreach

foreach입니다. Colored By Color Scripter 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace foreach_test { class Program { static void Main(string[] args) { int[] arr = new int[] { 1, 2, 3, 4, 5 }; foreach (int a in arr) { Console.WriteLine(a); } } } } 배열이나 컬렉션을 순차적으로 조회하면서 실행합니다. 변수 a에 arr의 첫값부터 순서대로 끝까지 들어갑니다. for문으로 고치면 아래와 같습니다. Colored By Color Scripter 1 2 3 4 5 6 7...


#IT·컴퓨터

원문링크 : [C#] foreach