접근 지정자(제한자)
 - Acces Modifier
 - 클래스 멤버의 보안 제어(캡슐화, 내부 은닉화)
 - public, private, protected, internal, protected internal
public
 -  클래스의 멤버를 100% 공개
 - 클래스 내부, 외부(다른
클래스), 파생클래스, 외부 파일 등..
 - 언제든지, 어디서나 접근 가능한 멤버를 만들고자 할때....
 - 메서드중 공개가 필요한건 public 그외의 메소드는 private
private
 - public의 정반대
 - 클래스의 멤버를 100% 비공개
 - 클래스 내부외엔 절대 접근 불가능 
 - public 에선 사용할 필요가 없고 선언한 클래스 내에서만 사용하기 위해서 만든것이다. 
 - 무조건 멤버 변수는 private으로 선언 한다.
 
외부 = 다른 클래스 오직 자기 클래스 안에서만 사용가능한것이
private 
인스턴스란 실제 메소드 및 클래스 객체안에 선언되는 객체들 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
       class Access
       {
             public static void Main(string[] args)
             {
                    //Student 클래스의 인스턴스를 생성한다.(객체를 만든다.)
                //Student타입(클래스)의 참조변수를 만든다. -주소값 저장
                    Student s1 = new Student();
                    
                    Console.Write("나이를 입력 : ");
                    int n = int.Parse(Console.ReadLine());
                    s1.SetAge(n);
                    s1.name = "김종현";
                    int age =
s1.GetAge();
                    Console.WriteLine("나이 : {0}", age);
                    s1.Hello();
                    
             }
       }
       class Student
       {
             //멤버 변수
             public string name;
             //1~100살 이내
             //무조건 감추자
             private int age;
             //인터페이스의 역활 (핸드폰 버튼, 모니터 전원 버튼 => public)
             public void SetAge(int n)
             {
                    if (n >= 1
&& n <= 100)
                           this.age =
n;
                    else
                           Console.WriteLine("나이를 잘못 입력 하였습니다.");
             }
             public int GetAge()
             {
                    return this.age;
             }
             //멤버 메서드
             public void Hello()
             {
                    //this 객체 연산자 or 객체 지정 연산자
                    Console.WriteLine("안녕하세요 저는 {0} 입니다. 나이는 {1}세 입니다.\n 태어난
년도는 {2}연도 입니다.", this.name,
this.age, this.GetYear());
             }
             //객체 내부에서만 사용하는 전용 메서드
             private int GetYear()
             {
                    return
DateTime.Now.Year - this.age;
             }
       }
}
Static 정적변수, 공용 변수
동시에 같이 사용할 변수 
목적 : 공간 낭비 최소화
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
       class Static
       {
             public static void Main(string[] args)
             {
                    //static 키워드 0, X
                    //객체변수 vs 정적변수
                    //객체메서드 정적메서드
                    //학생 3명 - 당산중학교
                    Student s1 = new Student();
                    s1.name = "가가가";
                    //s1.schoolName =
"당산중학교";
                    //클래스는 내부적으로 스태틱을 검색한다.(내부적으로
그렇게 만들어 놓은것)
                    Student.schoolName
= "당산중학교";
                    Student s2 = new Student();
                    s2.name = "나나나";
                    //s2.schoolName =
"당산중학교";
                    
                    Student s3 = new Student();
                    s3.name = "다다다";
                    //s3.schoolName =
"당산중학교";
                    s1.Hello();
                    s2.Hello();
                    s3.Hello();
             }
             class Student
             {
                    public string name;
                    //정적변수(공용변수)
                    //물리적인 구조상 객체에선 스태틱을 접근 할수 없다.
                    
                    public static string
schoolName;
                    public int age;
                    public void Hello()
                    {
                           Console.WriteLine("{0}에 다니는 {1}입니다.", Student.schoolName, this.name);
                    }
             }
       }
}
static 메인 메서드가 실행되기 전에 메모리에 올라온다.
객체를 만들때마다 생성되는것 ex) public int
객체를 만들때마다 생기지 않고 미리 메모리에 잡혀있는것  ex) static int
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
       class Static_02
       {
             public static void Main(string[] args)
             {
                    Test t1 = new
Test();
                    t1.a = 100;
                    Test.b = 200;
                    t1.M1();
                    Test.M2();
             }
             class Test
             {
                    public int a;
                    public static int b;
                    //객체 메서드
                    //자기 자신이 갖는 변수 , 자기 자신이
갖는 메서드, 정적 변수, 정적 메서드
                    public void M1()
                    {
                           Console.WriteLine("객체 메서드입니다.");
                           Console.WriteLine("
a : {0}, b : {1}", this.a, Test.b);
                    }
                    //정적 메서드
                    //정적 메서드 에서는 객체 멤버에 접근이 불가능 하다.
                    //this 사용불가x 정적으로 선언된것은 얼마든지
사용가능 
                    //정적 메서드 단점 : 공간 낭비가 심하다, 관리하기 위험하다.
                    public static void M2()
                    {
                           Console.WriteLine("정적 메서드입니다.");
                           Console.WriteLine("
a : {0}, b : {1}", a, Test.b);
                    }
             }
       }
}
하지만 참조되어 있는 변수에 다른 참조 변수가 복사가 되있다면 가비지가 되지 않으니 주의해야 한다.