score:12

Accepted answer

What are you expecting it to do? You probably want to make an actual method call there, such as:

var mailgroup = emails.Where(p =>IsValidFormat(p.Value))
                      .Select(p => p.Value);

Or if you just want the key/value pairs, you can just use:

var mailgroup = emails.Where(p =>IsValidFormat(p.Value));

and remove the "Select" entirely.

If you do just want the values (as per the first code snippet) I'd suggest using:

var mailgroup = emails.Values.Where(p =>IsValidFormat(p));

Without any brackets, your reference to "Select" is a method group - the kind of thing you'd convert to a delegate, e.g.

Func<int> x = SomeMethod; // Where SomeMethod is declared as "int SomeMethod()"

It doesn't really make sense to use Select as method group in this case, although it is just about feasible...

score:9

You're missing () after Select. As a result, what's being assigned to the variable is a reference to the Select method, which the compiler refers to as a 'method group'.

Incidentally, based on the code that you've posted I don't think that you need the trailing .Select() at all.


Related Query

More Query from same tag