Search

Feb 15, 2007

Compare two objects!!!


Use IComparer Generic Interface.

This interface provides


public int Compare(object x, object y)

you overiddes this method and implement yours, so simple right?


Example:


public class MyComparer : IComparer
{
public MyComparer() { }

public int Compare(object x, object y)
{
return DateTime.Compare(((MyClass)x).EntryDate, ((MyClass)y).EntryDate);
}

}
A delicious related to this topic!

No comments: