블로그 이미지
Magic_kit
study 관련자료를 한곳으로 자기 개발 목적으로 재태크 재무 관리 목적으로 일상생활의 팁을 공유 하기 위하여 블로그를 개설 하였습니다.

calendar

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

Category

Recent Post

Recent Comment

Archive

2009. 8. 11. 13:24 .Net Project/.Net 3.5 Sp1
반응형




using System;

namespace Field
{
    public class Car
    {
        //변수Variable Type
        public string name; //소문자로
        //상수Constant Type : static -> 정적접근
        public const int m_birth = 2010; //멤버변수의 의미
        //읽기전용필드 Read Only
        public static readonly string color = "Red"; //_언어바스코어->속성매치
             
    }
    public class Human
    {
        //이름을 저장할 공간 ? Field
        private string _Name;

        //이름을 외부에서 사용 : 속성(Property)
        public string Name
        {
            get {
                    return _Name;
                }
            set {
                    _Name = value;
                }
        }
    }
}
-----------------------------------------------------------
using System;
using Field; //네임스페이스 참조

public class 필드
{
    public static void Main()
    {
        //Field.Car car = new Field.Car();
        Car car = new Car();//Car클래스의 인스턴스 생성 의미
        car.name = "에쿠스"; //이렇게 하면 안된다 (X)
        // Car.color = "aa" Error
        // Car.m_birth = 2009; Error
        Human na = new Human(); //Human클래스의 인스턴스생성
        na.Name = "홍길동"; //설정(set)
        Console.WriteLine("이름 : {0}", na.Name); //사용(get)
    }
}

반응형

'.Net Project > .Net 3.5 Sp1' 카테고리의 다른 글

51장 Desctructor(소멸자)  (0) 2009.08.11
50장 Conistructor(생성자)  (0) 2009.08.11
48장 Class(클래스)  (0) 2009.08.11
47장 Locatioc(로케이션)  (0) 2009.08.10
46장 Document(문서)  (0) 2009.08.10
posted by Magic_kit