示例#1
0
        static void Main(string[] args)
        {
            string readPath  = @"E:\Учёба\3 сем\ООП\Лабы\LW8\input.txt";
            string writePath = @"E:\Учёба\3 сем\ООП\Лабы\LW8\output.txt";

            //Multitude<int> _mt1 = new Multitude<int>(1, 2, 3, 4, 5);
            //Console.WriteLine("Множество 1: {0}", _mt1);

            //Multitude<int> _mt2 = new Multitude<int>(4, 5, 6, 7, 8);
            //Console.WriteLine("Множество 2: {0}", _mt2);

            //_mt1.Print();
            //Console.WriteLine("Пересечение множеств: {0}", _mt1.Intersect(_mt2));
            //_mt2.Add(9);
            //Console.WriteLine("Множество 2 после добавления элемента: {0}", _mt2);
            //Console.WriteLine("Объединение множеств: {0}", _mt1.Union(_mt2));
            //_mt1.Delete(1);
            //Console.WriteLine("Множество 1 после удаления элемента: {0}", _mt1);
            //Console.WriteLine("Разность множеств: {0}", _mt1.Except(_mt2));


            List <double> nums1 = new List <double> {
                23.5, 65.4, 32.1, 9.0012
            };
            List <int> nums2 = new List <int> {
                27, 64, 128, 256
            };
            IMultitude <double> mul1 = new Multitude <double>(nums1);
            IMultitude <int>    mul2 = new Multitude <int>(nums2);
            Multitude <Button>  mul3 = new Multitude <Button>();
            Multitude <int>     mul4 = new Multitude <int>(nums2);

            try
            {
                mul1.Print();
                mul2.Print();
            }
            catch (Exception exception)
            {
                Console.WriteLine("Error: " + exception.Message);
                Console.WriteLine("Method: " + exception.TargetSite);
                Console.WriteLine("Source: " + exception.Source);
            }
            finally
            {
                Console.WriteLine("\nAll errors was processed");
            }
            using (StreamWriter sw = new StreamWriter(writePath, false, System.Text.Encoding.Default))
            {
                for (int i = 0; i < mul4.mulSize; i++)
                {
                    sw.Write(mul4.mulSize + " ");
                }
            }
            List <int> nums3 = new List <int>();

            using (StreamReader sr = new StreamReader(readPath, System.Text.Encoding.Default))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    nums3.Add(Convert.ToInt32(sr.ReadLine()));
                }
            }
            Multitude <int> mul5 = new Multitude <int>(nums3);

            mul5.Print();
            Console.ReadKey();
        }
示例#2
0
 public Multitude <T> Union(Multitude <T> Source) //объединение
 {
     return(new Multitude <T>(_list.Union(Source._list)));
 }
示例#3
0
 public Multitude <T> Except(Multitude <T> Source) //исключение
 {
     return(new Multitude <T>(_list.Except(Source._list)));
 }
示例#4
0
 public Multitude <T> Intersect(Multitude <T> Source) //пересечение
 {
     return(new Multitude <T>(_list.Intersect(Source._list)));
 }