I am trying to do a custom sort on using the following comparer:

public class ElementComparer : IComparer<QuestionElement>
{
public int Compare(QuestionElement x, QuestionElement y)
{
return (x.Index > y.Index) ? 1 : (x.Index < y.Index) ? -1 :
0;
}
}

I have the following code in the constructor of another object:

Then in the constructor of another class, I am trying to sort on a
List<U> like this:

public Set(T list)
{
_items = new List<U>();
//code to load collection
ElementComparer comparer = new ElementComparer();
_items.Sort(comparer); //WON'T COMPILE
}

The compiler error is cannot convert ElementComparer to
IComparer<U>. What am I doing wrong.

Thanks

Paul

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to