static void Main()
        {
            Student firstStudent = new Student("Pesho", "Peshev", "Peshev", 123456789, "Sofia", "0888736728",
                "*****@*****.**", 2, Specialties.Law, Universities.SU, Faculties.SF);
            Student secondStudent = new Student("Ivan", "Ivanov", "Ivanov", 124564789, "Varna", "0888678728",
                "*****@*****.**", 2, Specialties.Law, Universities.SU, Faculties.SF);
            Student thirdStudent = (Student)firstStudent.Clone();

            Console.WriteLine("Compare {0} and {1}: {2}", firstStudent.ToString(), secondStudent.ToString(), firstStudent.CompareTo(secondStudent));
            Console.WriteLine("Compare {0} and {1}: {2}", firstStudent.ToString(), thirdStudent.ToString(), firstStudent.CompareTo(thirdStudent));

            thirdStudent.Ssn = 123456790;
            Console.WriteLine("Compare {0} and {1} with different SSN: {2}", firstStudent.ToString(), thirdStudent.ToString(), firstStudent.CompareTo(thirdStudent));
        }
        public static void Main()
        {
            // Examples
            Student studentIvan = new Student("Ivan", "Manolov", "Kodev", 1175443445, "ul.Asenevci N3, Shumen", "+359895888333", "*****@*****.**", 3, University.Oxford, Specialty.French, Faculty.Alpha);
            Student studentDimcho = new Student("Dimcho", "Buhov", "Kostov", 1145345682, "ul.Padashti kotki, Sopot", "+359895123123", "*****@*****.**", 1, University.Harvard, Specialty.Biology, Faculty.Faculty3);

            // Crate array of Students
            Student[] students = new Student[] { studentIvan,studentDimcho};

            // Print
            Console.WriteLine("All students:\n");
            foreach (var student in students)
            {
                Console.WriteLine(student);
                Console.WriteLine();
            }

            // Check the overrited methods
            Console.WriteLine("\nIs Ivan == Dimcho?\n");
            Console.WriteLine(studentIvan == studentDimcho);

            Console.WriteLine("\nIs Ivan != Dimcho?\n");
            Console.WriteLine(studentIvan != studentDimcho);

            Console.WriteLine("\nIs Ivan equal to Dimcho?\n");
            Console.WriteLine(studentIvan.Equals(studentDimcho));

            Console.WriteLine("\nIvan compared with Dimcho:\n");
            Console.WriteLine(studentIvan.CompareTo(studentDimcho));

            Console.WriteLine("\nIvan HashCode:\n");
            Console.WriteLine(studentIvan.GetHashCode());
            Console.WriteLine("\nDimcho HashCode:\n");
            Console.WriteLine(studentDimcho.GetHashCode());

            Console.WriteLine("\nDimcho is copied...\n");
            var studentDimcho2 = studentDimcho.Clone();                         // Deep clone/sopy , element by element

            Console.WriteLine("\nIs DImcho compared with copied Dimcho?\n");
            Console.WriteLine(studentDimcho.CompareTo(studentDimcho2));

            Console.WriteLine("\nIs Dimcho equals to copied Dimcho?\n");
            Console.WriteLine(studentDimcho.Equals(studentDimcho2));           // Should be true

            Console.WriteLine("\nIs Dimcho equals to copied Dimcho by reference?\n");
            Console.WriteLine(ReferenceEquals(studentDimcho2,studentDimcho)); // Should be false
            Console.WriteLine("\nNice!");



            



        }
Exemple #3
0
        static void Main()
        {
            Student studentGosho = new Student("Georgi", "Georgiev", "Goshov", 1234545, "Vitosha 12", "08991234556", "*****@*****.**", 4, University.Technical, Faculty.Electronics, Specialty.Engineer);
            Student studentPesho = new Student("Pesho", "Peshev", "Dimov", 345678, "Dobdukov 14", "0898345678", "*****@*****.**", 3, University.UNSS, Faculty.Biology, Specialty.Doctor);

            Console.WriteLine(studentGosho);
            Console.WriteLine(studentPesho);

            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine(studentGosho.CompareTo(studentPesho));
        }
 static void Main()
 {
     var st1 = new Student() { FirstName = "Mimi", LastName = "Ivanova", SSN = 589762, Specialty = Specialty.Mathematics };
     var st2 = new Student() { FirstName = "Mimito", LastName = "Ivanova" };
     var st3 = new Student() { FirstName = "Mimi", LastName = "Ivanova", SSN = 125639, Specialty = Specialty.Informatics };
     Console.WriteLine(st1.Equals(st2));
     Console.WriteLine(st1.Equals(st3));
     Console.WriteLine(st1 == st2);
     Console.WriteLine(st1.ToString());
     Console.WriteLine(st3.GetHashCode());
     Console.WriteLine(st1.Clone().ToString());
     Console.WriteLine(st1.CompareTo(st3));
 }
Exemple #5
0
        public static void Main()
        {
            // Examples
            Student studentIvan   = new Student("Ivan", "Manolov", "Kodev", 1175443445, "ul.Asenevci N3, Shumen", "+359895888333", "*****@*****.**", 3, University.Oxford, Specialty.French, Faculty.Alpha);
            Student studentDimcho = new Student("Dimcho", "Buhov", "Kostov", 1145345682, "ul.Padashti kotki, Sopot", "+359895123123", "*****@*****.**", 1, University.Harvard, Specialty.Biology, Faculty.Faculty3);

            // Crate array of Students
            Student[] students = new Student[] { studentIvan, studentDimcho };

            // Print
            Console.WriteLine("All students:\n");
            foreach (var student in students)
            {
                Console.WriteLine(student);
                Console.WriteLine();
            }

            // Check the overrited methods
            Console.WriteLine("\nIs Ivan == Dimcho?\n");
            Console.WriteLine(studentIvan == studentDimcho);

            Console.WriteLine("\nIs Ivan != Dimcho?\n");
            Console.WriteLine(studentIvan != studentDimcho);

            Console.WriteLine("\nIs Ivan equal to Dimcho?\n");
            Console.WriteLine(studentIvan.Equals(studentDimcho));

            Console.WriteLine("\nIvan compared with Dimcho:\n");
            Console.WriteLine(studentIvan.CompareTo(studentDimcho));

            Console.WriteLine("\nIvan HashCode:\n");
            Console.WriteLine(studentIvan.GetHashCode());
            Console.WriteLine("\nDimcho HashCode:\n");
            Console.WriteLine(studentDimcho.GetHashCode());

            Console.WriteLine("\nDimcho is copied...\n");
            var studentDimcho2 = studentDimcho.Clone();                         // Deep clone/sopy , element by element

            Console.WriteLine("\nIs DImcho compared with copied Dimcho?\n");
            Console.WriteLine(studentDimcho.CompareTo(studentDimcho2));

            Console.WriteLine("\nIs Dimcho equals to copied Dimcho?\n");
            Console.WriteLine(studentDimcho.Equals(studentDimcho2));           // Should be true

            Console.WriteLine("\nIs Dimcho equals to copied Dimcho by reference?\n");
            Console.WriteLine(ReferenceEquals(studentDimcho2, studentDimcho)); // Should be false
            Console.WriteLine("\nNice!");
        }
        public static void Main()
        {
            Student firstStudent = new Student();
            Student secondStudent = new Student();
            secondStudent.Course = 5;
            secondStudent.FistName = "Pesho";
            secondStudent.SSN = 6;
            Console.WriteLine(firstStudent == secondStudent);
            Console.WriteLine(firstStudent.Equals(secondStudent));

            Student someStudent = (Student)secondStudent.Clone();
            someStudent.FistName = "Gosho";
            someStudent.SSN = 7;
            Console.WriteLine(secondStudent.FistName);
            Console.WriteLine(someStudent.FistName);
            Console.WriteLine(secondStudent.CompareTo(someStudent));
        }
        static void Main(string[] args)
        {
            Student peshoStud = new Student("Pesho", "Petrov", "Peshev", 9006036584, 1, "*****@*****.**", University.SofiaUniversity,
                                            Faculty.Physics, Specialty.Physics);
            Student ivanStud = new Student("Pesho", "Petrov", "Peshev", 9006036584, 1, "*****@*****.**", University.SofiaUniversity,
                                           Faculty.Physics, Specialty.Physics);

            Console.WriteLine(peshoStud.CompareTo(ivanStud));

            Console.WriteLine(peshoStud.Equals(ivanStud));
            Console.WriteLine(peshoStud.GetHashCode());
            Console.WriteLine(ivanStud.GetHashCode());
            Console.WriteLine(peshoStud.ToString());
            Console.WriteLine(peshoStud == ivanStud);
            Console.WriteLine(peshoStud != ivanStud);

            var cloned = ivanStud.Clone() as Student;

            Console.WriteLine(ivanStud.SSN);
            Console.WriteLine(cloned.SSN);
        }
        static void Main()
        {
            Student firstStudent = new Student("Pesho", "Peshev", "Peshev", 123456789, "Sofia", "0888736728",
                                               "*****@*****.**", 2, Specialties.Law, Universities.SU, Faculties.SF);
            Student secondStudent = new Student("Ivan", "Ivanov", "Ivanov", 124564789, "Varna", "0888678728",
                                                "*****@*****.**", 2, Specialties.Law, Universities.SU, Faculties.SF);
            Student thirdStudent = (Student)firstStudent.Clone();

            Console.WriteLine("Compare {0} and {1}: {2}", firstStudent.ToString(), secondStudent.ToString(), firstStudent.CompareTo(secondStudent));
            Console.WriteLine("Compare {0} and {1}: {2}", firstStudent.ToString(), thirdStudent.ToString(), firstStudent.CompareTo(thirdStudent));

            thirdStudent.Ssn = 123456790;
            Console.WriteLine("Compare {0} and {1} with different SSN: {2}", firstStudent.ToString(), thirdStudent.ToString(), firstStudent.CompareTo(thirdStudent));
        }