Esempio n. 1
0
        public static void Main()
        {
            StudentDetails st1 = new StudentDetails("sai", 500);
            StudentDetails st2 = new StudentDetails("Dinesh", 600);
            StudentDetails st3 = new StudentDetails("kumar", 400);

            StudentDetails[] sts = { st1, st2, st3 };


            Array.Sort(sts, StudentDetails.CompareByName);

            Display(sts);


            // Sort array by population.
            Array.Sort(sts, StudentDetails.CompareByMarks);
            Display(sts);


            Console.ReadKey();
        }
Esempio n. 2
0
 // comparing the student details based on the marks
 public static int CompareByMarks(StudentDetails s1, StudentDetails s2)
 {
     return(s1.Marks.CompareTo(s2.Marks));
 }
Esempio n. 3
0
 // comparing the student details based on the name
 public static int CompareByName(StudentDetails s1, StudentDetails s2)
 {
     return(String.Compare(s1.Name, s2.Name));
 }