示例#1
0
        static void Main(string[] args)
        {
            MyString hello = new MyString("Hello,");

            Console.WriteLine(hello);

            MyString world      = new MyString(" World!");
            MyString helloWorld = hello + world;

            Console.WriteLine(helloWorld);

            MyString helloWorldWorldWorld = hello + world + world + world;
            MyString helloWithoutWorlButWithPunktuation = helloWorldWorldWorld - new MyString("World");

            Console.WriteLine(helloWithoutWorlButWithPunktuation.ToString());

            MyString helloFromCharrArray = new MyString("Hello,".ToCharArray());

            Console.WriteLine(helloFromCharrArray);

            Console.WriteLine("Equals two string hello(first from string, second from char array: {0}",
                              hello == helloFromCharrArray);

            Console.WriteLine("Equals two string hello and world(first from string, second from char array: {0}",
                              hello == world);


            Console.ReadKey();
        }
示例#2
0
        static void Main(string[] args)
        {
            MyString a = new MyString("Hello");
            MyString b = new MyString("ll");
            MyString c = new MyString();

            Console.WriteLine("ToString method: " + a.ToString());
            c = a + b;
            MyString d = new MyString();

            d = a - b;
            if (a == b)
            {
                Console.WriteLine("Строки равны");
            }
            else
            {
                Console.WriteLine("Строки не равны");
            }
            if (a != b)
            {
                Console.WriteLine("Строки не равны1");
            }
            else
            {
                Console.WriteLine("Строки равны");
            }
            Console.WriteLine(a.Equals(b));
            Console.WriteLine(c.Text);
            Console.WriteLine(d.Text);
            Console.ReadKey();
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Введите строку:");
            string   a = Console.ReadLine();
            MyString s = new MyString(a); //Преобразование строки в массив символов

            Console.WriteLine("Ваша строка, преобразованная в массив:");
            s.Print(); // вывод массива символов
            Console.WriteLine("Введите строку для сравнения:");
            a = Console.ReadLine();
            if (s.Equals(a) == false)
            {
                Console.WriteLine("Строки не равны.");                       // сравнение массива и строки
            }
            else
            {
                Console.WriteLine("Строки равны.");
            }
            Console.WriteLine("Массив преобразованный в строку:");
            Console.WriteLine(s.ToString()); //преобразование массива в строку


            Console.Write("\nНажмите любую клавишу для закрытия программы.");
            Console.ReadKey();
        }
示例#4
0
        static void Main(string[] args)
        {
            MyString s1 = new MyString("string21");
            MyString s2 = new MyString("string2");
            MyString s3 = s1 - s2;
            string   s  = s3.ToString();

            Console.WriteLine(s);
            Console.ReadKey();
        }
示例#5
0
        static void Main(string[] args)
        {
            MyString myStringA = new MyString("ПРивет");
            MyString myStringB = new MyString("ПРивет");

            if (myStringA == myStringB)
            {
                Console.WriteLine("Строки равны.");
            }
            if (myStringA != myStringB)
            {
                Console.WriteLine("Строки не равны.");
            }
            myStringA += "123";
            Console.WriteLine(myStringA.ToString());
            myStringA -= "12";
            Console.WriteLine(myStringA.ToString());
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            MyString firstString  = new MyString("Hello my dear friend");
            MyString secondString = new MyString("Hi my dear friend");

            if (firstString.Equals(secondString))
            {
                Console.WriteLine("Lines are equal");
            }
            if (firstString != secondString)
            {
                Console.WriteLine("Lines are not equal");
            }
            firstString += "! How are you?";
            Console.WriteLine(firstString.ToString());
            firstString -= "How";
            Console.WriteLine(firstString.ToString());
            Console.ReadKey();
        }
示例#7
0
        static void Main(string[] args)
        {
            MyString str0   = new MyString("привет, как дела?");
            MyString str1   = new MyString(" как");
            string   str2   = str0 + str1;
            string   str3   = str0 - str1;
            bool     result = str0 == str1;

            str2 = str0.ToString();
        }
示例#8
0
        static void Main(string[] args)
        {
            MyString str1 = new MyString("abcd");
            MyString str2 = new MyString("bc");

            Console.WriteLine($"str1 = {str1.ToString()}, str2 = {str2.ToString()}");
            Console.WriteLine($"Is equals = {str1 == str2}");
            Console.WriteLine($"Is not equals = {str1 != str2}");
            Console.WriteLine($"Add str2 to str1: {str1 + str2}");
            Console.WriteLine($"Subtract str2 from str1: {str1 - str2}");
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("This program creates MyString class with own operators. Here is an examples:\n");
            MyString myStrHello = new MyString("Hello world");
            MyString myStrO     = new MyString("o");
            MyString myStrResult;

            myStrResult = myStrHello + myStrO;
            Console.WriteLine($"MyString \'{myStrHello.ToString()}\' + MyString \'{myStrO.ToString()}\' = {myStrResult.ToString()}.\n");

            myStrResult = myStrHello - myStrO;
            Console.WriteLine($"MyString \'{myStrHello.ToString()}\' - MyString \'{myStrO.ToString()}\' = {myStrResult.ToString()}.\n");

            Console.WriteLine($"Is MyString \'{myStrHello.ToString()}\' and MyString \'{myStrO.ToString()}\' are equals?: {myStrHello == myStrO}.\n");

            MyString myStrHelloCopy = new MyString("Hello world");

            Console.WriteLine($"Is MyString \'{myStrHello.ToString()}\' and MyString \'{myStrHelloCopy.ToString()}\' are equals?: {myStrHello == myStrHelloCopy}.\n");

            Console.WriteLine("\n\nEnd of program. Press any key.");
            Console.ReadKey();
        }
示例#10
0
        static void Main(string[] args)
        {
            MyString test = new MyString();

            test.str.AddRange("a12dfsd123fsdfs123qqq");
            MyString test2 = new MyString();

            test2.str.AddRange("123");
            MyString result = test - test2;

            Console.WriteLine(result.ToString());

            Console.ReadKey();
        }
示例#11
0
        static void Main(string[] args)
        {
            MyString s1 = new MyString("1string1");
            MyString s2 = new MyString("string");
            MyString s3 = new MyString("1string1");

            Console.WriteLine("Work with MyString:");
            Console.WriteLine($"Summ = {(s1 + s2).ToString()}");
            Console.WriteLine($"Difference = {(s1 - s2).ToString()}");
            Console.WriteLine($"Compare s1 and s2 is not equal {s1 != s2}");
            Console.WriteLine($"Compare s1 and s3 is equal {s1 == s3}");
            Console.WriteLine($"Strings - {s1.ToString()}, {s2.ToString()}, {s3.ToString()}");
            Console.ReadKey();
        }
示例#12
0
        static void Main(string[] args)
        {
            
            
            Console.WriteLine("Введите строку:");
            string a = Console.ReadLine();
            MyString s = new MyString(a); //Преобразование строки в массив символов
            Console.WriteLine("Ваша строка, преобразованная в массив:");
            s.Print(); // вывод массива символов
            Console.WriteLine("Введите строку для сравнения:");
            a = Console.ReadLine();
            if (s.Equals(a) == false) Console.WriteLine("Строки не равны."); // сравнение массива и строки
            else Console.WriteLine("Строки равны.");
            Console.WriteLine("Массив преобразованный в строку:");
            Console.WriteLine(s.ToString()); //преобразование массива в строку
            

            Console.Write("\nНажмите любую клавишу для закрытия программы.");
            Console.ReadKey();
        }