뇌를 자극하는 C# 5.0 프로그래밍 Chapter14 연습문제
1. 다음 코드의 출력 결과값은 얼마일까요?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | using System; namespace Ex14_1 { class MainApp { static void Main(string[] args) { Func<int> func_1 = () => 10; Func<int, int> func_2 = (a) => a * 2; Console.WriteLine(func_1() + func_2(30)); } } } | cs |
2. 출력 결과가 다음과 같이 나오도록 다음 코드에 이벤트 처리기를 추가하세요.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | using System; namespace Ex14_2 { class MainApp { static void Main(string[] args) { int[] array = { 11, 22, 33, 44, 55 }; foreach(int a in array) { Action action = () => Console.WriteLine(a * a); action.Invoke(); } } } } | cs |
'programming' 카테고리의 다른 글
뇌를 자극하는 C# 5.0 프로그래밍 Chapter13 연습문제 풀이 (0) | 2016.04.01 |
---|---|
뇌를 자극하는 C# 5.0 프로그래밍 Chapter12 연습문제 풀이 (0) | 2016.03.31 |
뇌를 자극하는 C# 5.0 프로그래밍 Chapter11 연습문제 풀이 (0) | 2016.03.30 |
뇌를 자극하는 C# 5.0 프로그래밍 Chapter10 연습문제 풀이 (0) | 2016.01.30 |
뇌를 자극하는 C# 5.0 프로그래밍 Chapter9 연습문제 풀이 (0) | 2016.01.08 |