검색결과 리스트
Multicast Delegate에 해당되는 글 1건
- 2010/08/26 멀티캐스트 대리자 샘플
글
멀티캐스트 대리자 샘플
37 #region 멀티캐스트 대리자 사용 샘플
38
39 delegate void Del(string s);
40
41 class TestClass {
42 static void Hello(string s) {
43 Console.WriteLine(" Hello, {0}!", s);
44 }
45
46 static void Goodbye(string s) {
47 Console.WriteLine(" Goodbye, {0}!", s);
48 }
49
50 public static void Test() {
51 Del a, b, c, d;
52
53 // Create the delegate object a that references
54 // the method Hello:
55 a = Hello;
56
57 // Create the delegate object b that references
58 // the method Goodbye:
59 b = Goodbye;
60
61 // The two delegates, a and b, are composed to form c:
62 c = a + b;
63
64 // Remove a from the composed delegate, leaving d,
65 // which calls only the method Goodbye:
66 d = c - a;
67
68 Console.WriteLine("Invoking delegate a:");
69 a("A");
70
71 Console.WriteLine("Invoking delegate b:");
72 b("B");
73
74 // A, B 둘다 호출됨
75 Console.WriteLine("Invoking delegate c:");
76 c("C");
77
78 // A, B 에서 A 가 빠진 B 만 호출됨
79 Console.WriteLine("Invoking delegate d:");
80 d("D");
81 }
82 }
83 /* Output:
84 Invoking delegate a:
85 Hello, A!
86 Invoking delegate b:
87 Goodbye, B!
88 Invoking delegate c:
89 Hello, C!
90 Goodbye, C!
91 Invoking delegate d:
92 Goodbye, D!
93 */
94
95 #endregion
'IT > Dot Net' 카테고리의 다른 글
| FileTracker : error FTK1011 (2) | 2010/09/03 |
|---|---|
| CopySourceAsHtml 에러 수정 (0) | 2010/08/27 |
| 멀티캐스트 대리자 샘플 (0) | 2010/08/26 |
| 중국어 간자체 변환 (0) | 2010/08/20 |
| [펌]About Box 에 관한 좋은 소스 (0) | 2010/02/18 |
| [펌] C# 팝업폼 Activate(API) (1) | 2010/01/12 |
