1번 다음 코드에서 문제를 찾고, 그 원인을 설명하세요.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
using System;
using System.Collections;
using System.Collections.Generic;
namespace ee
{
class MainApp
{
static void Main(string[] args)
{
Queue queue = new Queue();
queue.Enqueue(10); ;
queue.Enqueue("한글");
queue.Enqueue(3.14);
Queue<int> queue2 = new Queue<int>();
queue2.Enqueue(10);
queue2.Enqueue("한글");
queue2.Enqueue(3.14);
}
}
}
|
cs |
queue2.Enqueue("한글");
queue2.Enqueue(3.14);
는 int 형이기 때문에 정수만 입력이 가능하다.
2. 다음 코드에서 1)에 들어갈 내용은 무엇입니까?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
using System;
using System.Collections;
using System.Collections.Generic;
namespace ee
{
class MainApp
{
static void Main(string[] args)
{
Dictionary<string,string> dic = new Dictionary<string,string>();
dic["하나"] = "one";
dic["둘"] = "two";
dic["셋"] = "there";
dic["넷"] = "four";
dic["다섯"] = "five";
Console.WriteLine(dic["하나"]);
Console.WriteLine(dic["둘"]);
Console.WriteLine(dic["셋"]);
Console.WriteLine(dic["넷"]);
Console.WriteLine(dic["다섯"]);
}
}
}
|
cs |
'C#' 카테고리의 다른 글
클래스를 선언하고 객체를 생성하는 예제 프로그램 (0) | 2022.07.27 |
---|---|
델리게이트 기본 예제 (0) | 2022.07.26 |
뇌를 자극하는 C# 5.0 프로그래밍 연습문제 10장 4,5번 (0) | 2022.07.26 |
뇌를 자극하는 C# 5.0 프로그래밍 연습문제 10장 3번 (0) | 2022.07.26 |
뇌를 자극하는 C# 5.0 프로그래밍 연습문제 10장 2번 (0) | 2022.07.26 |