This is a method group conversion, and it's been available since C# 2. As a simpler example, consider:
public void Foo()
{
}
...
ThreadStart x = Foo;
ThreadStart y = new ThreadStart(Foo); // Equivalent code
Note that this is not quite the same as the lambda expression version, which will capture the variable table1
, and generate a new class with a method in which just calls IsChildOf
. For Any
that isn't important, but the difference would be important for Where
:
var usingMethodGroup = selectedTables.Where(table1.IsChildOf);
var usingLambda = selectedTables.Where(x => table1.IsChildOf(x));
table1 = null;
// Fine: the *value* of `table1` was used to create the delegate
Console.WriteLine(usingMethodGroup.Count());
// Bang! The lambda expression will try to call IsChildOf on a null reference
Console.WriteLine(usingLambda.Count());