You can use the
You can use the
MaxBy method in MoreLINQ. There's a similar question already on StackOverflow (it's in C#, though). You can use it like:
Return dic.MaxBy(Function(pair) pair.Value).Key
I did this like this:
(From kvp In dic Select kvp Where kvp.Value = dic.Values.Max).First.Key
Old question but I thought I'd provide my LINQ VB answer in case it helps others.
Return dic.Aggregate(Function(l, r) If(l.Value > r.Value, l, r)).Key
- How would I get the corresponding Key for the maximum Value in a Dictionary(Of SomeEnum, Integer) using LINQ?
- How to find the maximum value for each key in a List of Dictionaries using LINQ?
- How can I get LINQ to return the object which has the max value for a given property?
- LINQ - Writing an extension method to get the row with maximum value for each group
- Get the objects with the maximum value for a specific property from a list using LINQ
- How would I use LINQ to XML to get the value from example XML
- How do I traverse three tables and get the maximum of a value
- How to get the value by a key from a super nested Json
- How can I get the record which its value is the maximum
- How to get the value of a field from Lambda expression for ForEach()?
- How can I get the value of an attribute for a method that has duplicates?
- How to Properly Get the new Foreign Key Value Of Parent Id when Cloning object in EF core
- Using LINQ how would I check if a XML row contains a field and if it does check a different field on the same row for a value
- How to get the value by key and another value with linq? vbnet
- How to perform .Max() on a property of all objects in a collection and return the object with maximum value
- Good way to get the key of the highest value of a Dictionary in C#
- How do I get the index of the highest value in an array using LINQ?
- c# dictionary get the key of the min value
- How to get linq `ForEach` statement to return data on the method call being made for each list object?
- How do you get errors in the ModelState, for a particular property?
- How to get in LINQ one row for each key
- How do I get the value from a specific node in an XML file?
- How can I get LINQ to return the index of the object which has the max value in a collection?
- How to get the primary key from a table without making a second trip?
- How to get the xml attribute value of root?
- Get from a List<t> the record with the maximum value of a specific property
- Linq query, how to check for a null value and use the value 0 in place of a null?
- How to get bool value as returned object from the generics
- How to get the value of an XML element using Linq even when empty
- How to get the key when using linq Max() method
More Query from same tag
- Dynamic Linq for dates
- How do we retrieve the first item of a WhereSelectListIterator?
- Casting to a derived type in a LINQ to Entities query with Table Per Hierarchy inheritance
- EF Code First: Foreign Key With Where Clause?
- C# linq possible multiple enumeration best practices
- Using ToList() on Enumerable LINQ query results for large data sets - Efficiency Issue?
- SQL to LINQ inner JOIN
- LINQ select one bool from condition over multiple rows
- group by query with not in sub query linq
- Select and Cast to convert a Generic List into DataRow
- User is duplicated when calling Reply
- Optimize Linq in C#
- [LINQ]InsertOnSubmit NullReferenceException
- Entity Framework, LINQ Query
- Linq query with child items (Entity Framework)
- How can i copy data table records of different field name based on mapping list evaluating condition on source data table?
- LINQ result form 1:* relationship table -ASP.NET
- Fuzzy Search on a Concatenated Full Name using NHibernate
- how to update a field table by linq in C#?
- How to write T-SQL many-to-many with subquery in EF
- The LINQ expression could not be translated using Shadow Properties in MVC Core
- Fill Gridview using LINQ to DataSet query with alias
- Entity Framework Navigation Property One-to-Many becomes One-to-One
- LINQ Implementation query?
- Compare 2 lists and provide new list with updated quanities
- Normalizing a flat file with Linq
- Lambda Expression With Contains Not Working
- LINQ or DataTable when number of fields unknown
- Call method x times using linq
- linq to entities generated sql