본문 바로가기
Programming Language/이것이 C# 연습문제 풀이

이것이 C# 9장 연습문제 풀이

by dbxxrud 2019. 5. 13.

 

 

1. 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System;
using static System.Console;
namespace Practice2
{
    class NameCard
    {
        public int age { get; set; }
        public string name { get; set; }
    }
    class MainApp
    {
        public static void Main()
        {
            NameCard nameCard = new NameCard() { name = "상현", age = 24 };
            WriteLine("나이 : {0}", nameCard.age);
            WriteLine("이름 : {0}", nameCard.name);
        }
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4f; text-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none; color:white">cs

 

 

2.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
using System;
using static System.Console;
namespace Practice2
{
    class MainApp
    {
        public static void Main()
        {
            var nameCard = new { Name = "박상현", Age = "17" };
            WriteLine("이름 : {0}, 나이 : {1}", nameCard.Name, nameCard.Age);
 
            var complex = new { Real = "3", Imaginary = "-12" };
            WriteLine("Real : {0}, Imaginary : {1}", complex.Real, complex.Imaginary);
        }
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4f; text-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none; color:white">cs