Created
June 18, 2016 17:49
-
-
Save mfirhas/732af4d7ee3088a00a978927d6f7b757 to your computer and use it in GitHub Desktop.
Find Index of Max Value in a List C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int indexMax | |
= !intList.Any() ? -1 : | |
intList | |
.Select( (value, index) => new { Value = value, Index = index } ) | |
.Aggregate( (a, b) => (a.Value > b.Value) ? a : b ) | |
.Index; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment