반응형
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Collections.Generic;
using System.Text;
// C#에서 제공하는 기본 타입들 !!
// 1) 값형 (data형)  : int, char.( 기본타입) 구조체, 열거형
// 2) 참조형   :  pointer --> c/C++에서 포인터에 해당하는 변수들...
//   heap메모리를 사용하는 변수인가??  !!
// new 키워드를 통해 선언되어지는 변수들... class
 
 
namespace 기본타입
{
    // 값형식--> stack, static . 참조형이 아니기때문에 필요없음 !!
    struct Student
    {
        public int StudentNo;
        public string StudentName;
    }
 
    enum Color {  RED, GREEN, BLUE }
    class Program
    {
        static void Main(string[] args)
        {
            // C#의 식별자 !!
 
  /*          int Int; //?
            int 911;
            int 1num;
            int Student-No;
            int @name;
            int Student_name;
            int @StudentNon;
            */
 
            // 클래스이름 :  명사
            // 인터페이스 :  명사 +  형용사
            // 메소드 :  동사
            // 변수 :  명사
            // 파스칼 표기법을 기본으로 한다 !!
          //  PascalNo;
          //  KonYang;
 
 
 
            // 값형
       /*     Color color;
            color = (Color)1;
            Console.WriteLine( color.ToString() );
 
          // 값형타입 !!
            //내장형 (기본타입) :  int, float
            // 사용자 정의 : struct , enum
           // int,
            Student s;
            s.StudentName = "홍길동";
            s.StudentNo = 1000;
            */
            // 박싱과 언박싱 ( boxing , unbox)
            // 박싱 --> 값형식의 데이타를 참조형으로 변경 !!
            // 스택에 저장된 값형의 데이타를 heap으로 이동시키는 작업 !!
            int a = 10; // 스택 !!
            //박싱 -->
            Object o = (Object)a;
 
            Console.WriteLine(o.ToString());
            // 언박싱 !!
            int data = (int)o;
 
            Console.WriteLine(o.ToString());
             
            // 참조형 데이타 형식들...
            //  class
            //  인터페이스
            //  델리게이트
            //  배열
            //  string 
 
 
 
        }
    }
}

'C#' 카테고리의 다른 글

[C#] 배열  (0) 2014.11.18
[C#] 델리게이트 (Delegate)  (0) 2014.11.18
[C#] C# 언어의 특징  (0) 2014.11.18
[C#] C# 객체 지향 프로그래밍!!  (0) 2014.11.18
[C#] Object 클래스란  (0) 2014.11.18

+ Recent posts