[c#] enum practice



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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApplication1
{
    class Program
    {
        public enum COLOR { RED, BLUE, GREEN, BLACK }
        public enum MAKER { LG = 100, KIA, SK, LOTTE = 200, SAMSUNG = 300, HYUNDAI, GM }
 
        static void Main(string[] args)
        {
            Console.WriteLine("{0}"sizeof(COLOR));        //4
            Console.WriteLine("{0}", COLOR.RED);            //RED
            Console.WriteLine("{0}", (int)COLOR.RED);       //0
            Console.WriteLine("{0}", (int)COLOR.BLACK);     //3
 
            Console.WriteLine("{0}", MAKER.LG);             //LG
            Console.WriteLine("{0}", MAKER.KIA);            //KIA
            Console.WriteLine("{0}", (int)MAKER.LG);        //100
            Console.WriteLine("{0}", (int)MAKER.KIA);       //101
            Console.WriteLine("{0}", (int)MAKER.SK);        //102
            Console.WriteLine("{0}", (int)MAKER.LOTTE);     //200
            Console.WriteLine("{0}", (int)MAKER.SAMSUNG);   //300
            Console.WriteLine("{0}", (int)MAKER.HYUNDAI);   //301
            Console.WriteLine("{0}", (int)MAKER.GM);        //302
            Console.WriteLine("{0}", (int)MAKER.LG + MAKER.GM);        //402
 
            Console.WriteLine("{0}", MAKER.GM.GetTypeCode());   //Int32
 
            Console.ReadLine();
        }
    }
}
 
cs

댓글

이 블로그의 인기 게시물

[c#] DataTable을 dataGridView에 바인딩

[React] index.html 수정하기

[React] 프로젝트 생성