Meh, why make it overcomplicated? This is the simplest way.
var indexAtMax = scores.ToList().IndexOf(scores.Max());
Yeah, you could make an extension method to use less memory, but unless you’re dealing with huge arrays, you will never notice the difference.
More Related Contents:
- Prevent duplicates from array, based on condition [closed]
- Where is likely the performance bug here? [closed]
- Can’t use Count() in C#
- LINQ : Dynamic select
- What guarantees are there on the run-time complexity (Big-O) of LINQ methods?
- Bulk-deleting in LINQ to Entities
- What is LINQ and what does it do? [closed]
- Linq select objects in list where exists IN (A,B,C)
- Does Distinct() method keep original ordering of sequence intact?
- Deferred execution and eager evaluation
- What is the Efficiency and Performance of LINQ and Lambda Expression in .Net?
- ascending/descending in LINQ – can one change the order via parameter?
- How to select only the records with the highest date in LINQ
- Data binding directly to a store query (DbSet, DbQuery, DbSqlQuery) is not supported
- C# Linq intersect/except with one part of object
- Entity-framework code is slow when using Include() many times
- The operation cannot be completed because the DbContext has been disposed using MVC 4
- Linq to Objects – return pairs of numbers from list of numbers
- From Eric Lippert’s blog: “don’t close over the loop variable” [duplicate]
- Export Model to DataTable
- loading a full hierarchy from a self referencing table with EntityFramework.Core
- Max return value if empty query
- Sort one list by another
- Get sum of two columns in one LINQ query
- Add the where clause dynamically in Entity Framework
- Split a List into groups of consecutive numbers [closed]
- How to set property value using Expressions? [duplicate]
- Should the order of LINQ query clauses affect Entity Framework performance?
- Is Injection Possible through Dynamic LINQ?
- Can I use Linq’s Except() with a lambda expression comparer?