public static void OutTask()
        {
            Console.WriteLine("---- Изучение коллекций ----\n" +
                              "1.Описание библиотек, которые содержат коллекции.\n" +
                              "2.Класс ObservableCollection(Отличается от обычного списка тем, что имеет\n" +
                              "методы а также событие для оповещении об изменении объекта)\n" +
                              "3.Реализация IEnumerable и IEnumerator\n" +
                              "4.Итераторы и оператор yield");
            // 1.Collections:

            // System.Collections
            ArrayList arrayList = new ArrayList();
            Hashtable hashtable = new Hashtable();
            Queue     queue     = new Queue();
            Stack     stack     = new Stack();

            // System.Collections.Generic
            Dictionary <int, string> dict = new Dictionary <int, string>();
            List <int> list = new List <int>();
            SortedList <int, string> sortedList = new SortedList <int, string>();
            Stack <int> stack2 = new Stack <int>();
            Queue <int> queue2 = new Queue <int>();

            // System.Collections.Concurrent
            BlockingCollection <int>           blockingCollection = new BlockingCollection <int>();
            ConcurrentBag <int>                cBag   = new ConcurrentBag <int>();
            ConcurrentDictionary <int, string> cDict  = new ConcurrentDictionary <int, string>();
            ConcurrentQueue <int>              cQueue = new ConcurrentQueue <int>();
            ConcurrentStack <int>              cStack = new ConcurrentStack <int>();

            // Create a load-balancing partitioner. Or specify false for static partitioning.
            var nums = Enumerable.Range(0, 100000000).ToArray();
            Partitioner <int> partitioner2 = Partitioner.Create <int>(nums, true);
            OrderablePartitioner <Tuple <int, int> > customPartitioner = Partitioner.Create(0, nums.Length);

            // 2.ObservableCollection, library : System.Collections.ObjectModel, System.Collections.Specialized
            ObservableCollection <int> obj = new ObservableCollection <int>();

            obj.Count();
            obj.CollectionChanged += Obj_CollectionChanged;

            // 3.Реализация IEnumerable и IEnumerator
            Week week = new Week();

            foreach (var w in week)
            {
                Console.WriteLine(w.ToString());
            }

            Week2 week2 = new Week2();

            Console.WriteLine();
            while (week2.MoveNext())
            {
                Console.WriteLine(week2.Current);
            }
            week2.Reset();

            //4. Оператор yield
            Library library = new Library();

            foreach (var lib in library.GetBooks(5))
            {
                Console.WriteLine(lib.ToString());
            }
        }
Exemplo n.º 2
0
 public Lesson2Tests()
 {
     week2 = new Week2();
     rand  = new Random();
 }
Exemplo n.º 3
0
 static void Main(string[] args)
 {
     Week2.Run();
 }
Exemplo n.º 4
0
 static void Main(string[] args)
 {
     Week2 w2 = new Week2(1000);
     Console.WriteLine ("All done, press <enter> to exit");
     Console.ReadLine();
 }