I don't see any problems with this code, but it feels like I'm missing something. Maybe it is possible to reduce the number of lines. Or is there even a bug to be fixed? I'm open to any suggestions.
public class NameComparer : IEqualityComparer<FileInfo>
{
public bool Equals (FileInfo x, FileInfo y)
{
if (x == null) {
return y == null;
}
if (y == null) {
return false;
}
return x.Name.Equals (y.Name);
}
public int GetHashCode (FileInfo obj)
{
return obj.Name.GetHashCode ();
}
}