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 Query
- 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
More Query from same tag
- how to search an obj for a variable, given variable name as string
- Creating generic method
- Linq Grouping with Include
- Where clause in LINQ calling an async method
- MVC Viewmodel to display only model data
- How to update LINQ class before insert
- Dynamic linq nested group
- Select parent but order by certain child with dynamic linq
- Linq union usage?
- Diffrence between Students.Where(x=>x.City == "Lahore").ToList(); Students.ToList().Where(x=>x.City == "Lahore");
- Convert a string in a List<int> using LINQ (cleaner way)
- Cast IEnumerable<Inherited> To IEnumerable<Base>
- Get names of properties which are not null
- Converting array of objects to XML in C#
- How to create Linq Expression for DateTime.Date
- Entity Framework: retrieve row that is not in a Date range
- Optimizing LINQ routines
- Join in LINQ Query
- LINQ to SQL: Updating without Refresh when “UpdateCheck = Never”
- Entity Framework query student grade for a specific subject
- Is there a way in C# to use EXCEPT to compare 2 lists when one doesn't have Id yet?
- C# -Fetch Node Value and corresponding count for XML elements
- cannot reach my inner breakpoint
- How can i use generic class to write useful codes via linq?
- EF4 CTP5 - LINQ Dynamic Query Library throws InvalidCastException
- Entity Framework includes not working
- Selecting Particular Node List in XML
- The type '<>f__AnonymousType2`2[System.String,System.Int32]' must declare a default (parameterless) constructor
- Can I Linq query into multiple variables?
- I cant add a data into the sql via EF (Non static method requires a target)