Hej!
Chcę zrobić IEqualityComparer, który nie będzie czuły na wielkość znaków. Zrobiłem coś takiego:
public class MojComparer : IEqualityComparer<Char>
{
public bool Equals(Char x, Char y)
{
return x.ToString().ToLower() == y.ToString().ToLower();
}
public int GetHashCode(Char obj)
{
return obj.GetHashCode();
}
}
class Program
{
static void Main(string[] args)
{
string t = "Krzesło";
MojComparer c = new MojComparer();
Console.WriteLine(t.Contains("krz", c));
Console.ReadKey();
}
}
i zwraca mi błąd, w czasie kompliacji przy:
Console.WriteLine(t.Contains("krz", c));
Error 1 The type arguments for method 'System.Linq.Enumerable.Contains<TSource>(System.Collections.Generic.IEnumerable<TSource>, TSource, System.Collections.Generic.IEqualityComparer<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Ma ktoś jakiś pomysł jak mam to poprawić? pzdr