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
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