Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IComparer class giving error on compile 1

Status
Not open for further replies.

Micar

Programmer
Mar 9, 2007
2
US
Hi guys,

I'm new to C# so I'm trying to read tutorials and try different things. However, I've read a thousand tutorials on setting up an "IComparer" class. This function looks right to me but when I try to compile it (using the MSVC# 2005 Express Edition) I get this error:

Using the generic type 'System.Collections.Generic.IComparer<T>' requires '1' type arguments

Here's the code that I have:

public class FileInfoComparer : IComparer
{

public int Compare(Object d1, Object d2)
{
return String.Compare(
((FileInfo)d2).Name,
((FileInfo)d1).Name);
}
}

I'm just trying to do a simple comparer so that I can (eventually) sort a FileInfo[] array by filename alphabetically.

Thanks for your help!
Micah
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top