Alex Rivera | Logout

What is a method group in C#?

Asked 2009-05-20T08:31:23.810
414

I have often encountered an error such as "cannot convert from 'method group' to 'string'" in cases like:

var list = new List<string>();
// ... snip
list.Add(someObject.ToString);

of course there was a typo in the last line because I forgot the invocation parentheses after ToString. The correct form would be:

var list = new List<string>();
// ... snip
list.Add(someObject.ToString()); // <- notice the parentheses

However I came to wonder what is a method group. Google isn't much of a help nor MSDN.

Edit
Report

1 Answer

20

The ToString function has many overloads - the method group would be the group consisting of all the different overloads for that function.

answered 2009-05-20T08:36:39.603

Your Answer