Skip to content

Instantly share code, notes, and snippets.

@mfirhas
Created June 18, 2016 17:49
Show Gist options
  • Save mfirhas/732af4d7ee3088a00a978927d6f7b757 to your computer and use it in GitHub Desktop.
Save mfirhas/732af4d7ee3088a00a978927d6f7b757 to your computer and use it in GitHub Desktop.
Find Index of Max Value in a List C#
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