示例#1
0
        public static void TestEvent()
        {
            Lecturer avto = new Lecturer("avto rukhadze");

            Student ali = new Student("ali pirievi");
            Student oto = new Student("oto tumanishvili");
            Student temo = new Student("temo tutberidze");

            // davaregistrire, metodebi, romlebic gamoizaxeba SayHellos
            // moxdenisas
            avto.SayHello += ali.Answer;
            avto.SayHello += oto.Answer;
            avto.SayHello += temo.Answer;

            avto.Hello();
        }
        static void Main ( string[] args )
        {
            Delegates del = new Delegates();
            List<int> numbers = new List<int> { 5 , 4 , 8 , 7 , 9 , 6 , 6 , 6 , 3 , 1 , 20 };
            List<int> evens = del.FilterCollection(numbers , IsEven);
            foreach(var item in evens)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();
            AverageAggregator aggregator = new AverageAggregator();
            aggregator.AverageChanged += delegate ( object sender )
            {
                if(sender is AverageAggregator)
                {
                    AverageAggregator newSender = (AverageAggregator)sender;
                    Console.WriteLine("Average has changed!\nNew value: {0}" , newSender.Average);
                }
            };
            aggregator.AddNumber(6);
            aggregator.AddNumber(4);
            aggregator.AddNumber(2);
            aggregator.AddNumber(3);
            Student stu = new Student();
            stu.PropertyChanged += PropChange;
            stu.Name = "Anton";
            stu.FacultyNumber = 65888;
            stu.Grade = 5.58;

            NotifyCollection<int> newList = new NotifyCollection<int>();
            newList.PropertyChanged += (object sender, PropertyChangedEventArgs e)=>
        {
            Console.WriteLine("The list has changed!\n{0}" , e.PropertyName);
        };
            newList.Add(5);
            newList.Add(12);
            newList.Insert(1 , 20);
            newList.Remove(12);
            Console.ReadKey();
        }