score:12
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.
Source: stackoverflow.com
Related Articles
- Error with implicitly typed variables
- How do I filter a strongly typed list with List<String> variables
- Implicitly typed local variables must be initialised
- Implicitly typed local variables must be initialized
- Compiling Error with LINQ Sorting Code Using List<T>
- Trouble with a LINQ 'filter' code throwing an error
- Lambda expression with statement body error in previously working code
- What does this C# code with an "arrow" mean and how is it called?
- Create Dictionary with LINQ and avoid "item with the same key has already been added" error
- C# compilation error with LINQ and dynamic inheritance
- This code returns distinct values. However, what I want is to return a strongly typed collection as opposed to an anonymous type
- Is there some sort of syntax error with this LINQ JOIN?
- Error with Union in Linq to Entities
- Entity Framework - An item with the same key has already been added. - Error when trying to define foreign key relationship
- Why doesn't this code compile in VS2010 with .NET 4.0?
- why .ToList().Distinct() throws error but not the .Distinct().ToList() with linq query
- LINQ to SQL - Compile error when extending data context with partial class and methods
- JIT error with LINQ OrderBy using C# on iOS
- OrderByDescending with Skip and Take in LINQ shows error
- Why is this code with PredicateBuilder not working?
- C# 4.0 Implicitly Typed Dynamic Objects
- Query a byte property with nhibernate cause invalid cast error
- C# - Error CS1928: Checking for list element with derived class
- Can you advise me a resource with LINQ/lambda code exercises?
- LINQ query with two joins that worked in EF 6 gives error in EF 7
- Linq to SQL insert with primary key as tinyint set to auto-increment gives error message
- LINQ Source Code Available
- Linq to sql error with identitiy increment field
- Dynamic Linq Predicate throws "Unsupported Filter" error with C# MongoDB Driver
- Error with two structurally incompatible initializations within a single LINQ
- pass lambda expression as callback to an extension method and pass parameter to it
- NHibernate LINQ query Specified method is not supported error
- List comparison with double check on voucher no. and amount
- SQL grab all rows w/ left join greatest n by group
- Split a long string to a customized string
- LINQ queries with many-to-many tables in Entity Data Model
- Simplifying a Linq search in an HTMLAgilitypack document
- Based on date, get todays and the next two days values from XML?
- LINQ to Entities - sort by array
- How can i cast IQueryable<> query to IQueryable<obj.getType()>?
- LINQ join with distinct resultset
- LINQ to XML: suppressing redundant namespace attribute in child nodes
- Join columns of two CSV files using LINQ in C#.net
- Attempting to populate a dropdownlist through LINQ to entities in C#
- Linq Expression Tree - Concatenate Array of values
- Hide GridView Column using linq
- Can't get all tags from XML file
- Possible to group by Count in LINQ?
- C# Collection Filtering, where do I begin
- how to filter list in c# using linq