C# language feature:
applies to
benefit
how to use
see also
example:
class Method_Group_Conversion_Example
{
List<string> StringList = new List<string>();
void method_group_example()
{
StringList.Add("some string");
// Note that ForEach expects a delegate and a
// lambda expression is provided. The
// compiler unambiguously calls `System.Console.WriteLine(string)`
StringList.ForEach(str => System.Console.WriteLine(str));
// even "simpler" way to write without lamda expression
StringList.ForEach(System.Console.WriteLine); // example of method group conversion
// compiler determines based on type of List and method group which method
// of the various overloaded System.Console.WriteLine methods to resolve to
// as a string is passed in, method group resolves to `System.Console.WriteLine(string)`
// by passing, for example System.Console.WriteLine(Char)
}
}