Code:
SortedList sort = new SortedList();
sort.Add(new Fish("bin"),1);
sort.Add(new Fish("BIN"), 2);
foreach (DictionaryEntry entry in sort)
{
Console.WriteLine("{0} = {1}", entry.Key, entry.Value);
}
Code:
public class Fish : IComparer
{
string name;
public Fish(string theName)
{
name = theName;
}
public override bool Equals(object obj)
{
Fish f = obj as Fish;
if (f != null)
return String.Equals(name, f.name);
return false;
}
public override int GetHashCode()
{
return name.GetHashCode();
}
#region IComparer Members
public int Compare(object x, object y)
{
CaseInsensitiveComparer com = new CaseInsensitiveComparer();
return com.Compare(x, y);
}
#endregion
}
Error: "Failed to compare two elements in the array."