반응형
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
using System;
using System.Collections.Generic;
using System.Text;
 
namespace 필드멤버
{
    class Person
    {
        // const, readonly !!
        // 공통점 ?? 선언과 동시에 초기화가 가능하다..
        // 값을 변경 할수 없다 !!
        // 다른점???
        // const는 무조건 값을 변경할수 없고...
        // readonly 생성자에서만 값을 변경할수 있다 !!
        private static string nation;
        // static멤버는 static 프로퍼티로 ....
        public static string Nation
        {
            get { return Person.nation; }
            set { Person.nation = value; }
        }
        // 클래스의 멤버 변수를 선언과 통시에 초기화 !!
         private const string jumin = "910101";
         private readonly bool sex = false;
         public bool Sex
         {
             get { return sex; }
         }
         private string name;
         public string Name
         {
             get { return name; }
             set { name = value; }
         }
         private int age;
         public int Age
         {
             get { return age; }
             set { age = value; }
         }
        //프로퍼티  !!
         public string Jumin
         {
             get
             {
                 return jumin;
             }
         }
        // setter/getter
         public string getJumin() { return Jumin; }
         public bool getSex() { return sex; }
         public string getName() { return Name; }
        public int getAge( ){ return Age;  }
 
 
         public Person()
         {
       //      Jumin = "001111";
              sex = false;
 
         }
       // public void SetSex( bool b) {  sex = b; }
       // 소멸자 !!
          ~Person() // 오버로딩이 불가능 !!
         {
            
         }
    }
 
    class Program
    {
        static void Main(string[] args)
        {
            Person p = new Person();
            Person.Nation = "xxx";
 
        }
    }
}

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

[C#] 추상클래스  (0) 2014.11.18
[C#] 인터페이스  (0) 2014.11.18
[C#] 인덱서  (0) 2014.11.18
[C#] 이벤트  (0) 2014.11.18
[C#] 예외처리  (0) 2014.11.18

+ Recent posts