List<bool> test = new List<bool>(); test.Sort(new Func<bool,bool,int>((b1,b2) => 1));
我错过了什么?
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
当我有
private int func(bool b1,bool b2) { return 1; } private void something() { List<bool> test = new List<bool>(); test.Sort(func); }
它工作正常.他们不是一回事吗?