File: dotnet04.cs - Tab length: 1 2 4 8 - Lines: on off - No wrap: on off

01: 
02: class   MaClasse
03: {
04:     private Modifier<int>   modifier;
05:     private int             counter;
06: 
07:     public  MaClasse ()
08:     {
09:         this.modifier = new Modifier<int> (this.counterGet, this.counterSet);
10:         this.counter = 3;
11:     }
12: 
13:     public void     Test ()
14:     {
15:         Console.WriteLine ("avant: " + this.counter); // devrait afficher "avant: 3"
16: 
17:         this.modifier.SetValue (12);
18: 
19:         Console.WriteLine ("apr�s: " + this.counter); // devrait afficher "apr�s: 12"
20:     }
21: 
22:     // berk
23:     public int  counterGet ()
24:     {
25:         return this.counter;
26:     }
27: 
28:     // et re-berk
29:     public void counterSet (int value)
30:     {
31:         this.counter = value;
32:     }
33: }
34: 
35: class   Modifier<T>
36: {
37:     public delegate T       MyGetValue ();
38:     public delegate void    MySetValue (T value);
39: 
40:     private MyGetValue  getValue;
41:     private MySetValue  setValue;
42: 
43:     public  Modifier (MyGetValue getValue, MySetValue setValue)
44:     {
45:         this.getValue = getValue;
46:         this.setValue = setValue;
47:     }
48: 
49:     public void SetValue (T value)
50:     {
51:         this.setValue (value);
52:     }
53: }