yield1 C# yield문 § Yeild 문 § ◈ 호출자에게 컬렉션 데이터를 하나씩 리턴할 때 사용한다. - Collection : ArrayList, Stack, Queue, Hashtable... (Collection 정리 참조) class MyClass { static void Main(string[] args) { //int[] scores = new int[] {1, 2, 3 }; int[] arr = GetScores(); //foreach (var item in arr) foreach ( var item in GetScores()) { Console.WriteLine(item); } } static int[] GetScores( ) { int[] scores = new int[] { 1, 2, 3 }; return .. 2020. 12. 29. 이전 1 다음