using System;
class X
{
public static void Main ()
{
Action a = null;
bool res = a == Main; // ok
bool res1 = a == delegate {}; // Not allowed only method groups can do it
bool res2 = a == Foo; // Fails to bind
}
static int Foo ()
{
return 1;
}
}
Perhaps we need subsection here to describe method-group specific extension to delegate equality comparisons.
I don't know what was intended purpose of this but C# compiler allows to compare delegates and method groups when one side is a delegate and other side is a method group which can be converted to this delegate. Because method-group is never null the result is actually identical to delegate instance comparison to not-null.
Perhaps we need subsection here to describe method-group specific extension to delegate equality comparisons.
I don't know what was intended purpose of this but C# compiler allows to compare delegates and method groups when one side is a delegate and other side is a method group which can be converted to this delegate. Because method-group is never null the result is actually identical to delegate instance comparison to not-null.