Q:

About list sorting and delegates & lambda expressions Func stuff

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?

A:

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

