본문 바로가기

.NET/C# Basic

C# PPT 5 더보기
C# PPT 4 더보기
C# PPT 3 더보기
C# PPT 2 더보기
프로퍼티 관련소스 using System; using System.Collections.Generic; using System.Text; namespace pt1 { class Point1 { public int a; public int b; public Point1(int a,int b) { this.a = a; this.b = b; } } class Point2 { private int aa; private int bb; public void set(int aa,int bb) { this.aa = aa; this.bb = bb; } public int getaa() { return aa; } public int getbb() { return bb; } } class Point3 { private int xx; priv.. 더보기
프로퍼티 설명 get/set 아래 관련소스 2개중 한개는 인터넷에긁어왔고 나머지하나는 권오윤양소스입니다 소스만 보셔도 대충 이해되실꺼에염~!!! 프로퍼티를 설명하기전에 클래스를 보면 클래스는 엑세스 지정자라는 것을 통해 중요한 맴버를 외부로 부터 보호할수있죠 만약 모든 맴버를 외부에서 마음대로 릭고 쓸수 있다면 규칙에 맞지 않는 값이 들어올수 있어 객체의 무결성!!! 이 파괴 될것이라고하더군요~! 무결성이 훼손된 객체는 제대로 동작하지도 않을 뿐더러 언제 말썽을 일으킬지 알수없으므로 무척위험하답니다 그래서 프로퍼티get/set 을 쓰는것같군요 private는 함부로 읽거나 쓰지 못하도록 금지한겁니다 대신 공개된 get/set 메서드를 제공하지요~!!! 위에서스를 보면 대충 ~~ 요런거 public int XXX { get/set }.. 더보기
프로퍼티 예제 인터넷에서 긁어왔습니다 using System; class GAME { private string strTitle; private string strGenre; public string Title { get { Console.WriteLine("Title 프로퍼티의 get 호출"); return strTitle; } set { Console.WriteLine("Title 프로퍼티의 set 호출"); strTitle = value; } } public string Genre { get { Console.WriteLine("Genre 프로퍼티의 get 호출"); return strGenre; } set { Console.WriteLine("Genre 프로퍼티의 set 호출"); strGenre = value.. 더보기
프로퍼티 더보기