예제 #1
0
        static void Main(string[] args)
        {
            Random rand = new Random();
            MyNewCollection <PlacesV, PlacesV> Dic  = new MyNewCollection <PlacesV, PlacesV>();
            MyNewCollection <PlacesV, PlacesV> Dic1 = new MyNewCollection <PlacesV, PlacesV>();

            Dic.Name = "А";
            Journal journal1 = new Journal();
            Journal journal2 = new Journal();

            Dic.CollectionCountChanged      += new CollectionHandler(journal1.CollectionCountChanged);
            Dic.CollectionReferenceChanged  += new CollectionHandler(journal1.CollectionReferenceChanged);
            Dic.CollectionReferenceChanged  += new CollectionHandler(journal2.CollectionReferenceChanged);
            Dic1.CollectionReferenceChanged += new CollectionHandler(journal2.CollectionReferenceChanged);
            for (int i = 0; i < 5; i++)
            {
                Thread.Sleep(50);
                Dic.Add(PlacesV.RandAdd(rand), PlacesV.RandAdd(rand));
            }
            for (int i = 0; i < 5; i++)
            {
                Thread.Sleep(50);
                Dic1.Add(PlacesV.RandAdd(rand), PlacesV.RandAdd(rand));
            }
            Dic[1] = new DictionaryCommon <PlacesV, PlacesV> .Point(PlacesV.RandAdd(rand), PlacesV.RandAdd(rand));

            Dic1[1] = new DictionaryCommon <PlacesV, PlacesV> .Point(PlacesV.RandAdd(rand), PlacesV.RandAdd(rand));

            Dic.Remove(1);
            Console.WriteLine("Журнал 1");
            Console.WriteLine(journal1.ToString());
            Console.WriteLine("Журнал 2");
            Console.WriteLine(journal2.ToString());
        }
예제 #2
0
파일: Program.cs 프로젝트: Bergess258/neXT
        private static void GettingMinMax(List <List <PlacesV> > Places)
        {
            PlacesV Place   = (from list in Places from place in list select place).Max();
            PlacesV PlaceL  = (Places.SelectMany(list => list.ToArray().Select(place => place))).Min();
            PlacesV PlaceAN = Places.SelectMany(delegate(List <PlacesV> list) { return(list.ToArray().Select(delegate(PlacesV place) { return place; })); }).Max();

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Запрос 5");
            Console.ResetColor();
            Console.WriteLine("linq Самое короткое название места");
            Console.WriteLine(Place);
            Console.WriteLine("Лямбда Самое длинное название места");
            Console.WriteLine(PlaceL);
            Console.WriteLine("Анонимные методы Самое короткое название места");
            Console.WriteLine(PlaceAN);
        }