Hi
Requirement :
Create a program named SchoolsDemo that allows a user to enter data about five school objects and then displays the school objects in order of enrollment size from smalles to largest. The school class contains fields for the school name and number of students enrolled and properties for each field. Also, include an Icompareable.CompareTo() method so that School Objects can be sorted by enrollment.
What i have done : Starting issue itself unable to understand what question really expecting from me . But i am trying to find out
Any ideas ,
Regards

VulpesPosted Feb 13, 2014, 5:39 PM
VulpesPosted Feb 10, 2015, 4:09 PM
If you don't know what that is, then check out this link:
http://www.trinity.nottingham.sch.uk/computing/csharp/basics/bubbleSort.aspx
Jay PatelPosted Feb 10, 2015, 1:12 PM
how would the program look like then?
VulpesPosted Feb 14, 2014, 7:29 AM
The interface has only one method CompareTo which takes an object parameter (another instance of the current type) and returns an int.
If the return value is less than 0, then the current instance will precede the other instance in the sort order.
If the return value is 0, then the current and other instances will have the same position in the sort order.
If the return value is more than 0, then the current instance will follow the other instance in the sort order.
Methods such as Array.Sort automatically (unless instructed to the contrary) use a type's CompareTo method to sort the elements of the array.
So here, after checking that the object is of the right type and is not null, we make use of System.Int32's own CompareTo method to compare the _enrolment fields of the two instances.
The array is then sorted in increasing order of _enrolment.
It's more normal nowadays to use the generic version of IComparable which is strongly typed but, as the question didn't specify this, I've stuck to the non-generic version.
SUNIL GUTTAPosted Feb 14, 2014, 2:26 AM
Once again Ty so much
Well before me looking into code you given . I need some clarity on what the question really need ..
I understand fields inside properties .. but what is the main theme of the question ..
Please explain me so i can try my self and next look into the code given by you
Regards