How do I get the index of the highest value in an array using LINQ?

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.

Leave a Comment