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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace cshapExTwo6 { class Program { static void Main(string[] args) { /* * 접근 제한자/한정자 * public, private, protected, internal, protected internal, private protected * cf)한정자가 설정되지 않았을 경우 private로 기본 설정된다 * * public : 클래스의 내부 또는 외부 모든 곳에서 접근 가능 * private : 클래스 외부에서는 접근을 할 수 없음 * protected : 클래스 외부에서 접근할 수 없으나 파생클래스에서만은 접근이 가능 * internal : 동일 어셈브리에 있는 코드에서만 접근가능(외부라이브러리에서 접근 불가) * protected internal : 동일 어셈블리에 있는 코드에서만 protected로 접근 * private protected : 동일 어셈블리에 있는 클래스에서 상속받은 클래스 내부에서만 접근 * * */ Demo.public_method(); //Demo.protected_method(); //Demo.private_method(); Demo.internal_method(); Demo.protected_internal(); //Demo.private_protected(); } class Demo { public Demo() { Demo.public_method(); Demo.protected_method(); Demo.private_method(); Demo.internal_method(); Demo.protected_internal(); Demo.private_protected(); } //public public static void public_method() { } //protected protected static void protected_method() { } //private private static void private_method() { } //internal internal static void internal_method() { } //protected internal protected internal static void protected_internal() { } //private protected private protected static void private_protected() { } } class Demo2 : Demo { public Demo2() { Demo.public_method(); Demo.protected_method(); //Demo.private_method(); Demo.internal_method(); Demo.protected_internal(); Demo.private_protected(); } } } } | cs |
'프로그래밍' 카테고리의 다른 글
2_7.상속관계에서 클래스간의 형변환 (0) | 2019.01.21 |
---|---|
2_6.상속(base키워드, sealed키워드) (0) | 2019.01.20 |
2_4.this() (0) | 2019.01.18 |
2_3. 얕은복사와 깊은복사 (0) | 2019.01.16 |
2_2. static필드 (0) | 2019.01.16 |
댓글