List<bool> test = new List<bool>();
test.Sort(new Func<bool, bool, int>((b1, b2) => 1));
What Am I missing?
Error 2 Argument 1: cannot convert from 'System.Func' to 'System.Collections.Generic.IComparer'
Error 1 The best overloaded method match for 'System.Collections.Generic.List.Sort(System.Collections.Generic.IComparer)' has some invalid arguments
When I have
private int func(bool b1, bool b2)
{
return 1;
}
private void something()
{
List<bool> test = new List<bool>();
test.Sort(func);
}
it works fine. Are they not the same thing?
Func is the wrong delegate type. You can use either of these:
test.Sort((b1, b2) => 1);
test.Sort(new Comparison<bool>((b1, b2) => 1));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With