반응형
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