Esempio n. 1
0
        public void Happened(object o, EventArgs e)
        {
            StaticExample staticExample = o as StaticExample;
            MyEventArgs   myEventArgs   = e as MyEventArgs;

            myEventArgs.ShowArgs();

            //e.ShowArgs();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // Action - тип делегата (public delegate void Action)
            Action a = () => Console.Write("A");

            var myDelegate = new Mydelegate(SomeMethod); // экземпляр делегата
            var result     = AddText(myDelegate, 5);

            Console.WriteLine(result);


            Boozer vasya = new Boozer();

            vasya.OilNeeded += OilNeeded;
            vasya.myEvent   += myDelegate;
            vasya.GetDrunk();

            {
                // кортежи
                var tuple1 = (5, 10, "sdc");

                (int first, string second)tuple2 = (first : 5, second : "vs"); // name
            }



            Example1 example1 = new Example1();
            Hendler1 hendler1 = new Hendler1();
            Hendler2 hendler2 = new Hendler2();

            example1.Notify += hendler1.message;
            example1.Notify += hendler2.message;

            example1.Count();


            StaticExample staticExample = new StaticExample();

            staticExample.staticEvent += Stat1.Meth;
            staticExample.Go("davai");


            //staticExample.evn += new EventHandler(StaticExample_evn);


            SomeGettingClass someGettingClass = new SomeGettingClass();

            staticExample.evn += someGettingClass.Happened;
            staticExample.GoEventHendler();
        }