Are there any benefits to using a C# method group if available?

Well, let’s take a look and see what happens. static void MethodGroup() { new List<string>().ForEach(Console.WriteLine); } static void LambdaExpression() { new List<string>().ForEach(x => Console.WriteLine(x)); } This gets compiled into the following IL. .method private hidebysig static void MethodGroup() cil managed { .maxstack 8 L_0000: newobj instance void [mscorlib]System.Collections.Generic.List`1<string>::.ctor() L_0005: ldnull L_0006: ldftn void [mscorlib]System.Console::WriteLine(string) L_000c: … Read more

Overloaded method-group argument confuses overload resolution?

First off, I note that this is a duplicate of: Why is Func<T> ambiguous with Func<IEnumerable<T>>? What’s the exact problem here? Thomas’s guess is essentially correct. Here are the exact details. Let’s go through it a step at a time. We have an invocation: “test”.Select<char, Tuple<char>>(Tuple.Create); Overload resolution must determine the meaning of the call … Read more

What is a method group in C#?

A method group is the name for a set of methods (that might be just one) – i.e. in theory the ToString method may have multiple overloads (plus any extension methods): ToString(), ToString(string format), etc – hence ToString by itself is a “method group”. It can usually convert a method group to a (typed) delegate … Read more