반응형
뇌를자극하는 C#.md

뇌를 자극하는 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<intint> 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 = { 1122334455 };
 
            foreach(int a in array)
            {
                Action action = () => Console.WriteLine(a * a);     
                action.Invoke();
            }
        }
    }
}
cs

출력결과




반응형

+ Recent posts