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


class   MaClasse
{
        private Modifier<int>   modifier;
        private int                             counter;

        public  MaClasse ()
        {
                this.modifier = new Modifier<int> (this.counterGet, this.counterSet);
                this.counter = 3;
        }

        public void             Test ()
        {
                Console.WriteLine ("avant: " + this.counter); // devrait afficher "avant: 3"

                this.modifier.SetValue (12);

                Console.WriteLine ("apr�s: " + this.counter); // devrait afficher "apr�s: 12"
        }

        // berk
        public int      counterGet ()
        {
                return this.counter;
        }

        // et re-berk
        public void     counterSet (int value)
        {
                this.counter = value;
        }
}

class   Modifier<T>
{
        public delegate T               MyGetValue ();
        public delegate void    MySetValue (T value);

        private MyGetValue      getValue;
        private MySetValue      setValue;

        public  Modifier (MyGetValue getValue, MySetValue setValue)
        {
                this.getValue = getValue;
                this.setValue = setValue;
        }

        public void     SetValue (T value)
        {
                this.setValue (value);
        }
}