Esempio n. 1
0
        static void Main()
        {
            PointList set = new PointList();

            set.Add(new Point(4, 5));
            set.Add(new Point(4, 5));
            set.Add(new Point(4, 5));
            set.Add(new Point(7, 1));
            set.Add(new Point(7, 2));
            set.Add(new Point(5, 2));
            set.Add(new Point(7, 2));
            Console.WriteLine("Список точек на плоскости:");
            foreach (Point p in set)
            {
                Console.WriteLine(p.ToString());
            }
            // Обработка списка в LINQ-запросах:
            IEnumerable <Point> newList =
                from v in set
                orderby v.Mod
                select v;

            //set.OrderBy(d => d.Mod);  // аналог приведенного запроса
            Console.WriteLine("Список упорядоченных точек:");
            foreach (Point p in newList)
            {
                Console.WriteLine(p.ToString());
            }

            var res = from r in set
                      where r.Mod > 7
                      select r;

            //Console.WriteLine(res.GetType());
            Console.WriteLine("Список точек c модулем большим 7:");
            foreach (Point p in res)
            {
                Console.WriteLine(p.ToString());
            }
            Console.ReadKey();
        }   // void Main
Esempio n. 2
0
 // Конструктор:
 public PointEnumerator(PointList pointList)
 {
     _list    = pointList;
     curIndex = -1;
     curPoint = default(Point);
 }