IComparable Interface
This interface is a mode to do comparison of two objects of a given type... This is used when you want to provide ordering/sorting capabilities for you object...
If you have an array of your object and you wish to call the sort method on that array, the implementation of this interface will help do the sorting... To implement IComparable you need to override the CompareTo method in the following way
int IComparable.CompareTo(object obj)
{
Person objPerson =(Person)obj;
return String.Compare(this.firstName.Trim() & this.lastName.Trim()
,objPerson.firstName.Trim() & objPerson.lastName.Trim());
}
PS: There is a wonderful festival celebrated in Gujarat, India called Navratri which is beginning this weekend... Nav-Ratri means Nine-Nights and that's how long the festival is celebrated... In this festival there are folk dances done called Garbas and Dandiyas... Dandiya is the folk dance which is done by holding small sticks in hand and making rhythmic moves and touching the sticks in the hands of your partner... In Gujarat, you would find nearly all the streets flooded upto dawn with people in cultural dresses during this festival... In my home town Baroda, Gujarat there are grounds set up where close to 10,000 (probably even more) people can dance at the same time... As usual even in these cultural events girls get free admission and guys have to buy passes to enter the dance floors... One fine day we will have to start... "Men's libralization" movement...
Btw, we have Navratri celebrations nearly in every city of US too... Though not that grand but not bad at all... So this weekend will be fun...
No comments:
Post a Comment