[c#] Dictionary practice2




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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApplication5
{
    class Student
    {
        public string Id { get; set; }
        public string Name { get; set; }
        public string Address { get; set; }
 
        public Student(string id, string name, string address)
        {
            Id = id;
            Name = name;
            Address = address;
        }
    }
 
    class Score
    {
        public int Math { get; set; }
        public int Korean { get; set; }
        public int English { get; set; }
        public int Science { get; set; }
 
        public Score(int math, int korean, int english, int science)
        {
            Math = math;
            Korean = korean;
            English = english;
            Science = science;
        }
    }
 
    class Program
    {
        static void Main(string[] args)
        {
            var score_list = new Dictionary<Student, Score>();
 
            score_list.Add(new Student("001""KIM""Seoul"), new Score(60803050));
            score_list.Add(new Student("002""SIM""Deagu"), new Score(65901060));
            score_list.Add(new Student("003""JOO""Deagu"), new Score(80705070));
            score_list.Add(new Student("004""LIM""Deagu"), new Score(90507080));
            score_list.Add(new Student("005""YOU""Seoul"), new Score(70129090));
 

            foreach (KeyValuePair<Student, Score> a in score_list)
            {
                Console.WriteLine("ID:{0}, NAME:{1}, ADDRESS:{2}  --> MATH:{3}, KOREAN:{4}, ENGLISH:{5}"
                    a.Key.Id.ToString(),
                    a.Key.Name.ToString(),
                    a.Key.Address.ToString(),
                    a.Value.Math.ToString(),
                    a.Value.Korean.ToString(),
                    a.Value.English.ToString());
            }
 
            System.Console.ReadLine();
        }
    }
 
    
}
 
cs

댓글

이 블로그의 인기 게시물

[c#] DataTable을 dataGridView에 바인딩

[React] index.html 수정하기

[React] 프로젝트 생성