当前位置: 首页>>代码示例>>C#>>正文


C# Student.Equals方法代码示例

本文整理汇总了C#中Student.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Student.Equals方法的具体用法?C# Student.Equals怎么用?C# Student.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Student的用法示例。


在下文中一共展示了Student.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main()
        {
            Student firstStudent = new Student("Grigor", "Grigorov", "Dimitrov", 123456789, "Best 40 Str.", "+359 887 256 025", "[email protected]", "3", Specialty.Inssurance, University.UNSS, Faculty.GeneralEconomics);

            Student secondStudent = new Student("Georgi", "Ivanov", "Stoianov", 231456789, "George 21A Str.", "+359 887 256 025", "[email protected]", "2", Specialty.ComputerScience, University.SofiaUniversity, Faculty.ComputerScience);

            var thirdStudent = firstStudent.Clone() as Student;
            Console.WriteLine("Compare first student and second student using Equal: {0}", firstStudent.Equals(secondStudent));
            Console.WriteLine("Compare first student and second student using == operator: {0}", firstStudent == secondStudent);
            Console.WriteLine("Compare first student and third student using Equal: {0}", firstStudent.Equals(thirdStudent));
            Console.WriteLine("Compare first student and third student using != operator: {0}", firstStudent != thirdStudent);

            Console.WriteLine();
            Console.WriteLine("Changing the SSN of the third student, which is clone of the first student!");
            thirdStudent.SSN = 122456789;
            Console.WriteLine("Compare first student and third student using Equal: {0}", firstStudent.Equals(thirdStudent));
            Console.WriteLine();
            Console.WriteLine("The result of comparing first student with third student is: {0}", firstStudent.CompareTo(thirdStudent));

            Console.WriteLine();
            Console.WriteLine("Printing the all information for the first student using ToString method!");
            Console.WriteLine(firstStudent);

            Console.WriteLine();
            Console.WriteLine("Test for class Person!");
            Person firstPerson = new Person("Ivan Ivanov Ivanov");
            Person secondPerson = new Person("Grigor Grigorov Dimitrov", 23);
            Person thirdPerson = new Person("Pesho", "Peshev", "Peshev");
            Console.WriteLine();
            Console.WriteLine(firstPerson);
            Console.WriteLine();
            Console.WriteLine(secondPerson);
            Console.WriteLine();
            Console.WriteLine(thirdPerson);
        }
开发者ID:tzigy,项目名称:TelerikAcademy,代码行数:35,代码来源:StudentAndPersonTest.cs

示例2: Main

        static void Main()
        {
            var student1 = new Student("John", "Atanasov", "421586353");

            var studentEqual = new Student("John", "Atanasov", "421586353");
            Console.WriteLine("Different objects with the same properties are equal: {0}",student1.Equals(studentEqual));
            Console.WriteLine();

            Student student1DeepCopy = student1.Clone();
            Console.WriteLine("The copy and the original are the same: {0}", student1.Equals(student1DeepCopy));
            Console.WriteLine("The copy reference the original -> " + ReferenceEquals(student1, student1DeepCopy));
            Console.WriteLine();

            var student2 = new Student("John", "Atanasov", "421586353");
            var student3 = new Student("Peter", "Nikolov", "245124749");
            CompareStudents(student1, student2);
            CompareStudents(student1, student3);
            CompareStudents(student2, student3);
            Console.WriteLine();

            Console.WriteLine(student1.ToString());
            Console.WriteLine();

            student1.MiddleName = "Ivanov";
            student1.MobilePhone = "0885123456";
            student1.Faculty = Faculty.Bachelor;
            student1.University = University.SU;
            Console.WriteLine(student1.ToString());
            Console.WriteLine();
        }
开发者ID:cvet-,项目名称:Telerik_Academy,代码行数:30,代码来源:Program.cs

示例3: Main

        static void Main()
        {
            Student student1 = new Student("Ivan", 1234);
            Student student2 = new Student("Pesho", 123);

            // makes check with equals
            Console.WriteLine("student1 is equals to student2 = {0}",student1.Equals(student2));
            // makes check with !=
            if (student1 != student2)
            {
                Console.WriteLine("{0} != {1}", student1, student2);
            }

            // makes second student to be equal to first
            student2.FirstName = "Ivan";

            // makes again two types check
            Console.WriteLine("student1 is equals to student2 = {0}", student1.Equals(student2));
            if (student1 == student2)
            {
                Console.WriteLine("{0} == {1}", student1, student2);
            }

            // checks if are Clone method is deep
            Student student3 = student1.Clone();
            student3.FirstName = "Mitko";
            Console.WriteLine(student1.FirstName);
            student3.Specialty = Specialty.Marketing;
            Console.WriteLine(student1.Specialty);

            // test compare method
            Console.WriteLine(student1.CompareTo(student2));
        }
开发者ID:ilian-ivanov,项目名称:Telerik-Academy,代码行数:33,代码来源:Test.cs

示例4: Main

        static void Main(string[] args)
        {
            Student firstStudent = new Student("Ivan", "Georgiev", "Petrov", 543943113, "Sofia", "+359854332356",
                "[email protected]", 3, Specialties.ComputerScience, Faculties.FMI, Universities.SU);

            Student secondStudent = new Student("Todor", "Dimitrov", "Hristov", 7643265123, "Sofia", "+359834651209",
                "[email protected]", 3, Specialties.ComputerScience, Faculties.FMI, Universities.SU);

            Console.WriteLine(firstStudent);
            Console.WriteLine(secondStudent);

            Console.WriteLine(firstStudent.GetHashCode());
            Console.WriteLine(secondStudent.GetHashCode());
            Console.WriteLine();

            Console.WriteLine(firstStudent.Equals(secondStudent));
            Console.WriteLine(firstStudent == secondStudent);
            Console.WriteLine(firstStudent != secondStudent);
            Console.WriteLine();

            Student studentClone = (Student)firstStudent.Clone();
            Console.WriteLine(firstStudent.Equals(studentClone));
            Console.WriteLine(firstStudent == studentClone);
            Console.WriteLine(firstStudent != studentClone);
            Console.WriteLine();
        }
开发者ID:MarinaGeorgieva,项目名称:TelerikAcademy,代码行数:26,代码来源:TestStudent.cs

示例5: Main

    static void Main()
    {
        Student studOne = new Student("Nikolai", "Iliev", "Kirilov", 8741, "Sofiq", 0884125741, "[email protected]", 3, 
                                        Specialty.Telecommunications, University.SU, Faculty.Telecommunications);
        Student studTwo = new Student("Stanislav", "Krasimirov", "Ivanov", 2478, "Varna", 0894715687, "[email protected]", 1,
                                        Specialty.Mathematics, University.VINS, Faculty.Mathematics);
        Student studThree = new Student("Nikolai", "Iliev", "Kirilov", 8741, "Sofiq", 0884125741, "[email protected]", 3,
                                        Specialty.ArtsOfMarketing, University.VINS, Faculty.Business);

        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine("StudOne equal StudTwo: {0}" , studOne.Equals(studTwo));
        Console.WriteLine("StudOne equal StudThree: {0}", studOne.Equals(studThree));
        Console.WriteLine();
        Console.WriteLine("StudOne == StudTwo: {0}", studOne == studTwo);
        Console.WriteLine("StudOne == StudThree: {0}", studOne == studThree);
        Console.WriteLine();
        Console.WriteLine("StudOne HashCode: {0}", studOne.GetHashCode());
        Console.WriteLine("StudTwo HashCode: {0}", studTwo.GetHashCode());
        Console.WriteLine();
        Console.WriteLine("StudOne Deep Clone in StudFour...");
        Student studFour = studOne.Clone();
        Console.WriteLine();
        Console.WriteLine("Print StudFour: ");
        Console.ResetColor();
        Console.WriteLine(studFour);
        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine("StudOne compare to StudTwo: {0}", studOne.CompareTo(studTwo));
    }
开发者ID:BorislavIvanov,项目名称:Telerik_Academy,代码行数:28,代码来源:AppTest.cs

示例6: Main

        static void Main(string[] args)
        {
            Console.Title = "Students";

            Student st1 = new Student("Ivan", "Petkov", "Minev", "123456", "ul.Nishava №1", "+359883554422", "[email protected]", 3, Specialty.ComputerScientce, University.SofiaUniversity, Faculty.Computers);
            var st2 = st1.Clone();

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(st1);
            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine(st2);
            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Student1 equals student2 ? : {0}", st1.Equals(st2));
            Console.WriteLine("Student1 compare to student2 ? : {0}", st1.CompareTo(st2));

            Console.WriteLine();

            st2.FirstName = "Georgi";

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(st1);
            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine(st2);
            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Student1 equals student2 ? : {0}", st1.Equals(st2));
            Console.WriteLine("Student1 compare to student2 ? : {0}", st1.CompareTo(st2));
            Console.WriteLine();

            st1.FirstName = "Georgi";
            st2.SSN = "123459";
            st2.Address = "ul. James Bourchier №123";

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(st1);
            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine(st2);
            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Student1 equals student2 ? : {0}", st1.Equals(st2));
            Console.WriteLine("Student1 compare to student2 ? : {0}", st1.CompareTo(st2));

            Console.WriteLine();
            Console.ResetColor();
        }
开发者ID:nikolay-radkov,项目名称:Telerik-Academy,代码行数:55,代码来源:Demo.cs

示例7: Main

        static void Main()
        {
            Student first = new Student("Boyan", "Hristov", "Georgiev", 123, "Sofia, 48, Vasil Levski Blvd",
                "98888888", "[email protected]", University.UNSS, Faculty.InformaticsFaculty, Specialty.IT, 1);

            Console.WriteLine("Original:" + first);

            Student cloned = first.Clone();

            Console.WriteLine("Cloned:{0}", cloned);

            Console.WriteLine("First and Cloned are the same students: {0}", first.Equals(cloned));

            Console.WriteLine(new string('-', 50));

            cloned.SSN = 2323;
            Console.WriteLine("Cloned :{0} with changed SSN", cloned);
            Console.WriteLine("Original of the cloned {0}", first);

            Console.WriteLine("First and Cloned are the same students after the change of SSN of cloned: {0}", first.Equals(cloned));
            Console.WriteLine(new string('-', 50));

            Console.WriteLine("Other three students:");
            Student second = new Student("Ivanka", "Ivanova", "Kancheva", 12111, "Sofia, 64, Hristo Botev Blvd",
                "088888128", "[email protected]", University.NewBulgarianUniversity, Faculty.LiteratureFaculty, Specialty.IT, 2);
            Console.WriteLine(second);
            Student third = new Student("Penka", "Mincheva", "Manolova", 23400, "Sofia, 44, Hristo Botev Blvd",
                "088888123", "[email protected]", University.NewBulgarianUniversity, Faculty.LiteratureFaculty, Specialty.IT, 2);
            Console.WriteLine(third);
            Student fourth = new Student("Anna", "Georgieva", "Manova", 4646, "Sofia, 44, Hristo Botev Blvd",
               "088888123", "[email protected]", University.NewBulgarianUniversity, Faculty.MathematicsFaculty, Specialty.Litrature, 2);
            Console.WriteLine(fourth);

            List<Student> sortedStudents = new List<Student>();
            sortedStudents.Add(first);
            sortedStudents.Add(second);
            sortedStudents.Add(cloned);
            sortedStudents.Add(third);
            sortedStudents.Add(fourth);

            sortedStudents.Sort();

            Console.WriteLine(new string('-', 50));
            Console.WriteLine("The sorted students are:");

            foreach (var student in sortedStudents)
            {
                Console.WriteLine(student);
            }
        }
开发者ID:stoyanovalexander,项目名称:TheRepositoryOfAlexanderStoyanov,代码行数:50,代码来源:TestStudentInfo.cs

示例8: Main

    static void Main()
    {
        Student first = new Student("Ivan", "Iliev", "Ivanov", 9999, "Sofia, 22, Slivnitza Blvd", "0888888888",
            "[email protected]", 2, Specialties.Engineering, Universities.TechnicalUniversity, Faculties.MechanicallEngineering);

        Console.WriteLine("Original:" + first);

        Student cloned = first.Clone();

        Console.WriteLine("Cloned:{0}", cloned);

        Console.WriteLine("First and Cloned are the same students: {0}", first.Equals(cloned));

        Console.WriteLine();

        cloned.SSN = 2323;
        Console.WriteLine("Cloned :{0} with changed SSN", cloned);
        Console.WriteLine("Original of the cloned {0}", first);

        Console.WriteLine("First and Cloned are the same students after the change of SSN of cloned: {0}", first.Equals(cloned));
        Console.WriteLine();

        Console.WriteLine("Other students:");
        Student second = new Student("Iliana", "Ivanova", "Savova", 12111, "Sofia, 64, Bulgaria Blvd", "0888888128",
            "[email protected]", 2,Specialties.Chemistry,Universities.SofiaUniversity,Faculties.Chemistry);
        Console.WriteLine(second);
        Student third = new Student("Penka", "Mincheva", "Manolova", 23400, "Sofia, 84, Vasil Levski Blvd", "0888988123",
            "[email protected]",3,Specialties.Biotechnology,Universities.SofiaUniversity,Faculties.Biology);
        Console.WriteLine(third);
        Student fourth = new Student("Anton", "Georgiev", "Milev", 4646, "Sofia, 49, Hristo Botev Blvd", "0888887123",
            "[email protected]",1,Specialties.ComputerSystems,Universities.TechnicalUniversity,Faculties.IT);
        Console.WriteLine(fourth);

        List<Student> sortedStudents = new List<Student>();
        sortedStudents.Add(first);
        sortedStudents.Add(second);
        sortedStudents.Add(cloned);
        sortedStudents.Add(third);
        sortedStudents.Add(fourth);

        sortedStudents.Sort();

        Console.WriteLine();
        Console.WriteLine("The sorted students are:");

        foreach (var student in sortedStudents)
        {
            Console.WriteLine(student);
        }
    }
开发者ID:bankoff,项目名称:TelerikAcademy,代码行数:50,代码来源:TestProgram.cs

示例9: Main

    static void Main()
    {
        Student stud1 = new Student("Samuel", "L.", "Jackson", 14362, "Klokotnica 17",
            "555", "[email protected]", University.Harvard, Faculty.Engineering, Speciality.ComputerScience, 1);

        Console.WriteLine("Original student -  " + stud1);

        Student cloned = stud1.Clone();

        Console.WriteLine("Cloned student - {0}", cloned);

        Console.WriteLine("First and Cloned are the same students: {0}", stud1.Equals(cloned));

        Console.WriteLine(new string('*', 70));

        cloned.SSN = 55555;
        Console.WriteLine("Cloned  - {0} with changed SSN", cloned);
        Console.WriteLine("Original of the cloned -  {0}", stud1);

        Console.WriteLine("First and Cloned are the same students after the change of SSN of cloned: {0}", stud1.Equals(cloned));
        Console.WriteLine(new string('*', 70));

        Console.WriteLine("Other 3 students:");
        Student stud2 = new Student("Gugi", "Dudev", "Mudev", 13555, "Klokotnica 17",
            "555", "[email protected]", University.Blumingdales, Faculty.Sciences, Speciality.Mathemathics, 2);
        Console.WriteLine(stud2);
        Student stud3 = new Student("Damqn", "Ignatiev", "Djambazov", 17555, "Klokotnica 17",
            "555", "[email protected]", University.MIT, Faculty.Medicine, Speciality.DentalMedicine, 2);
        Console.WriteLine(stud3);
        Student stud4 = new Student("Sandra", "The", "Smurf", 18555, "Klokotnica 17",
            "555", "[email protected]", University.Brown, Faculty.Philosophy, Speciality.Informatics, 2);
        Console.WriteLine(stud4);

        List<Student> sortedStudents = new List<Student>();
        sortedStudents.Add(stud1);
        sortedStudents.Add(stud2);
        sortedStudents.Add(cloned);
        sortedStudents.Add(stud3);
        sortedStudents.Add(stud4);

        sortedStudents.Sort();

        Console.WriteLine(new string('*', 70));
        Console.WriteLine("The sorted students are:");

        foreach (var student in sortedStudents)
        {
            Console.WriteLine(student);
        }
    }
开发者ID:Jarolim,项目名称:HomeWork,代码行数:50,代码来源:TestStudent.cs

示例10: Main

        /*Define a class Student, which contains data about a student – first, middle and last name, SSN, permanent
         *address, mobile phone e-mail, course, specialty, university, faculty. Use an enumeration for the specialties, 
         *universities and faculties. Override the standard methods, inherited by  System.Object: Equals(), ToString(), 
         *GetHashCode() and operators == and !=.
        */

        static void Main()
        {
            //initialize students
            Student s = new Student("Ivan", "Ivanov", "Ivanov", "1713218", Specialty.Mathematics, University.SofiaUni, Faculty.FMI);
            Student p = new Student("Ivan", "Ivanov", "Ivanov", "713218", Specialty.Mathematics, University.SofiaUni, Faculty.FMI);
            s.Address = "sss";
            s.E_mail = "smail";

            //test Equals()
            Console.WriteLine(p);
            Console.WriteLine();
            Console.WriteLine(s);
            Console.WriteLine();
            Console.WriteLine(s.Equals(p));
            Console.WriteLine();

            //test Clone()
            Student k = s.Clone();
            k.Faculty = Faculty.FE;
            k.Address = "kkkkk";
            k.E_mail = "kmail";
            Console.WriteLine(k.ToString());
            
            //test CompareTo()
            Console.WriteLine("\nCompareTo:");
            Student c = new Student("Ivan", "Ivanov", "Ivanov", "13218", Specialty.Mathematics, University.SofiaUni, Faculty.FMI);
            Console.WriteLine(c.CompareTo(k));
        }
开发者ID:Varbanov,项目名称:TelerikAcademy,代码行数:34,代码来源:StudentMain.cs

示例11: IsEqual2

 private static void IsEqual2(Student p1, Student p2)
 {
     Console.WriteLine("IsEqual2:");
     Console.WriteLine("Equals: {0}", p1.Equals(p2));
     Console.WriteLine("==:     {0}", p1 == p2);
     Console.WriteLine();
 }
开发者ID:riezebosch,项目名称:cnetin1,代码行数:7,代码来源:Program.cs

示例12: Main

        static void Main()
        {
            Student georgiStudent = new Student("Georgi", "Ivanov", "Petrov", 12345678, "Sofia, ul.Oborishte 15", "+359888777666",
                "[email protected]", 2, University.SU, Faculty.FMI, Speciality.AppliedMathematics);
            Console.WriteLine(georgiStudent);
            Console.WriteLine();

            Student ivanStudent = new Student("Ivan", "Ivanov", "Georgiev", 12345679, "Plovdiv, ul.Trakia 18", "+359888777555",
                "[email protected]", 2, University.UACEG, Faculty.FacultyOfStructuralEngineering, Speciality.StructuralEngineering);
            Console.WriteLine(ivanStudent);

            Student georgiStudentTwo = new Student("Georgi", "Ivanov", "Petrov", 123456799, "Sofia, ul.Oborishte 15", "+359888777666",
                "[email protected]", 2, University.SU, Faculty.FMI, Speciality.AppliedMathematics);
            Console.WriteLine(georgiStudent);
            Console.WriteLine();

            Console.WriteLine(georgiStudent.Equals(ivanStudent));
            Console.WriteLine(georgiStudent == georgiStudentTwo); //това трябва да е True
            Console.WriteLine(georgiStudent != georgiStudentTwo); //това трябва да е False
            Console.WriteLine(georgiStudent.GetHashCode());
            Console.WriteLine(ivanStudent.GetHashCode());

            Student ivanCloning = (Student)ivanStudent.Clone();
            Console.WriteLine(ivanCloning);

            Console.WriteLine(georgiStudent.CompareTo(ivanStudent)); //-1, т.е. georgiStudent  е пред ivanStudent в подреждането/сравнението
            Console.WriteLine(ivanStudent.CompareTo(ivanCloning)); //0
        }
开发者ID:MarinMarinov,项目名称:C-Sharp-OOP,代码行数:28,代码来源:TheMain.cs

示例13: Main

    internal static void Main()
    {
        // Task 1: 
        // Define a class Student, which contains data about a student.
        // Override the standard methods, inherited by  System.Object:
        // Equals(), ToString(), GetHashCode() and operators == and !=.
        Student stu1 = new Student("Billy", "Bob", 2939025702, University.Stanford, Faculty.Engineering, Specialty.ComputerScience);
        Student stu2 = new Student("John", "Chambers", 6536025741, University.Harvard, Faculty.Business, Specialty.Management);

        Console.WriteLine("stu1: {0}", stu1);
        Console.WriteLine("stu2: {0}", stu2);

        Console.WriteLine("stu1 hash code: {0}", stu1.GetHashCode());
        Console.WriteLine("stu2 hash code: {0}", stu2.GetHashCode());

        Console.WriteLine("stu1 == stu2 -> {0}", stu1 == stu2);
        Console.WriteLine("stu1 != stu2 -> {0}", stu1 != stu2);
        Console.WriteLine("stu1.Equals(stu2) -> {0}", stu1.Equals(stu2));

        // Task 2: Clone
        Student stu3 = (Student)stu1.Clone();
        Console.WriteLine("stu1 clone: {0}", stu3);

        // Task 3: Compare
        Console.WriteLine("stu1 > stu2 -> {0}", stu1.CompareTo(stu2));
        Console.WriteLine("stu1 > stu3 -> {0}", stu1.CompareTo(stu3));
    }
开发者ID:MarKamenov,项目名称:TelerikAcademy,代码行数:27,代码来源:Program.cs

示例14: Main

        static void Main()
        {
            //int res = "Atanas".CompareTo("Branimir");

            Student equalStud1 = new Student("Pesho", "Georgiev", "Stratiev", 215677, "Sofia 1440, str.Todor Aleksandrov #12", "[email protected]", "0895623333", "OOP", Speciality.Programing, Univercity.TelerikAcademy, Faculty.InforamtionScience);
            Student equalStud2 = new Student("Pesho", "Ivanov", "Stratiev", 215677, "Sofia 3215, bul.Goce Delchev #16", "[email protected]", "0825953378", "UIDesign", Speciality.Mobiletechnologies, Univercity.TelerikAcademy, Faculty.InforamtionScience);
            Console.WriteLine(equalStud1);
            Console.WriteLine("Hash code of {1}: {0}", equalStud1.GetHashCode(), equalStud1.PfirstName);
            Console.WriteLine("\n{0}", equalStud2);
            Console.WriteLine("Hash code of {0}: {1}", equalStud2.PfirstName, equalStud2.GetHashCode());
            Console.WriteLine("---------\nAre students equal: " + equalStud1.Equals(equalStud2) + "\n");  // true

            Student diffStud1 = new Student("Evlogi", "Ivanov", "Hristov", 215677, "Munchen , blv.Hainz", "[email protected]", "+034525234", "OOP", Speciality.Infomationtechnologies, Univercity.SoftwareAcademy, Faculty.InforamtionScience);
            Student diffStud2 = new Student("Nikolay", "Ivanov", "Kostov", 215677, "Sofia 1440, str.Aleksander Malinov", "[email protected]", "0875723731", "OOP", Speciality.ComputerScince, Univercity.TelerikAcademy, Faculty.InforamtionScience);
            Console.WriteLine("Comparing new students: {0} and {1}\n Result: {2}", diffStud1.PfirstName, diffStud2.PfirstName, diffStud2.Equals(diffStud1));
            Console.WriteLine("{0} == {1} : {2}  \n{0} != {1} : {3}", diffStud1.PfirstName, diffStud2.PfirstName, diffStud1 == diffStud2 ,diffStud1 != diffStud2);
            //Cloning
            Console.WriteLine("\n----Try to clone----\n");
            // Change setting to copied object and then compare them

            var fullCopyofStudent = (Student)diffStud1.Clone();
            Console.WriteLine("Comparing new object with old: {0}\n", fullCopyofStudent == diffStud1);
            fullCopyofStudent.PfirstName = "Doncho"; // Important !!! Changing name ...
            Console.WriteLine("Change first name to new obj. Are they equals: {0}\n Answer: newObj.FirstName = {1}\n\t oldObj2.FirstName = {2}", fullCopyofStudent == diffStud1 , fullCopyofStudent.PfirstName , diffStud1.PfirstName);
            //Comparing

            Console.WriteLine("\n----Try to compare----\n");
            ComparingObjs(equalStud1.CompareTo(equalStud2)); // equalStud1 & equalStud2;
            ComparingObjs(diffStud1.CompareTo(diffStud2)); //diffStud1 & diffStud2
            ComparingObjs(equalStud2.CompareTo(fullCopyofStudent)); // equalStud2 & fullCopyofStudent
        }
开发者ID:viktorD1m1trov,项目名称:T-Academy,代码行数:31,代码来源:MainMethodHere.cs

示例15: Main

        public static void Main()
        {
            Student firstStudent = new Student("Pesho", "Georgiev", "Ivanov", "Sofia", "+3849384398",
                "[email protected]", 3122, Specialties.Telecommunications, Universities.TU, Faculties.Law);

            Student secondStudent = new Student("Dancho", "Ivanov", "Petrov", "Plovdiv", "039483439",
                "[email protected]", 23453, Specialties.IT, Universities.NBU, Faculties.Mathematics);

            Console.WriteLine("First student HashCode: " + firstStudent.GetHashCode());
            Console.WriteLine("Second student HashCode: " + secondStudent.GetHashCode());
            Console.WriteLine("First student equals second student: " + firstStudent.Equals(secondStudent));
            Console.WriteLine("First student == second student: " + (firstStudent == secondStudent));
            Console.WriteLine("First student != second student: " + (firstStudent != secondStudent));
            Console.WriteLine();
            Console.WriteLine(secondStudent.ToString());
            Console.WriteLine();

            Student thirdStudent = (Student)secondStudent.Clone();

            Console.WriteLine("Second student == third student: " + (secondStudent == thirdStudent));
            Console.WriteLine("Second student != third student: " + (secondStudent != thirdStudent));
            Console.WriteLine("Second student.CompareTo(third student): " + secondStudent.CompareTo(thirdStudent));
            Console.WriteLine("First student.CompareTo(Second student): " + firstStudent.CompareTo(secondStudent));
            Console.WriteLine(firstStudent.ToString());
            Console.WriteLine(secondStudent.ToString());
            Console.WriteLine(thirdStudent.ToString());
        }
开发者ID:etcet1,项目名称:TelerikAcademy,代码行数:27,代码来源:StudentTest.cs


注:本文中的Student.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。