score:3
Accepted answer
You can't do this very easily in plain LINQ to Objects, unfortunately. You could find the minimum value and then find the Coord
which has that value, but obviously that means going over the data twice.
I have a MinBy
method in MoreLINQ which you could use though:
Coord minCoord = myCoords.MinBy(c => myArray[c.Row, c.Col]);
score:0
Another less than elegant answer:
coords.Single( x => array[x.Row, x.Col] == coords.Min(y => array[y.Row,y.Col]));
Source: stackoverflow.com
Related Articles
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Why can't I call an extension method from a base class of the extended type?
- Enumerable.Cast<T> extension method fails to cast from int to long, why?
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- linq extension method to take elements from the end of the sequence
- Is there any way to use an extension method in an object initializer block in C#
- How does one tell if a LINQ extension method is suffering from double enumeration?
- When selecting an anonymous type with LINQ from EF, is there no way to run a method on an object as you select it?
- creating Linq to sqlite dbml from DbLinq source code
- How to get object from .Min extension method?
- Why the extension method of where for LINQ in this code would print out a single number while it shouldn't print anything at all?
- Extension method not updating object passed in
- Can someone tell me why this simple bit of c# code won't work, involves recursively calling method from within itself to get the root category ID
- Can I Return Different Types From An Extension Method
- Linq extension method equivalent for that code in VB.NET
- Linq code to get the index of an object in an array from an object within a list
- From Linq To List Using Extension Method
- How to instantiate object from string using Linq New method and provide a constructor parameter?
- How to code an Or extension method
- C# exclude duplicate code from two method returning expression
- Calling a shared code from Page method and WebApi Controller with Razor Pages
- Take a sequence of elements from an array from i to j using C# and extension method
- Can I get a Func object for an Extension method
- Using LINQ's Except<> method with an object from an external API
- Extension method to get last element from IQueryable<T>
- c# Linq or code to extract groups from a single list of source data
- Create list of runtime-known type from object list and call generic method
- Get value from expression in linq extension method
- Create a list from two object lists with linq
- What is the use of Enumerable.Zip extension method in Linq?
- How to perform this query in LINQ?
- Left join with linq
- Most efficient way to call linq on a list of information objects?
- Linq Query Not Returning Value
- how to write a Linq query with a EF code first Many to Many relationship
- Web API OData media type formatter when using $expand
- Return list of remaining elements in C#
- Linq order by conditional
- Linq Union ordering - how do i ensure items from the first IEnumerable remain first in result?
- How to convert SQL to linq for this query
- LINQ Join with multiple or conditions
- Generic type inference
- AsQueryable() does not return needed type in custom LINQ query using Lightswitch
- XElement: a collection of all the leaves?
- How to check if a control is child of another control? "Control.IsChildOf"
- Better Linq parsing of Large XML data
- Get maximum value in a list within a list in LINQ
- Querying Access database vb.net
- How to quickly transform a List(Of Object) into a List(Of "Object.field")?
- Visual Studio .Net source stepping for System.Linq