-2

I have a list of integers and I want to find out the position of the biggest integer in my list.

List<int> members = new List<int>({312, 33, 122, 3979, 8712, 88})

I tried getting the biggest number by doing int max = members.Max(); and then I tried to get its index like this int highestMember = members.FindIndex(max); but it doesn't work this way

dozenme
  • 23
  • 6
  • why not sort the list and call the last item in the index? https://stackoverflow.com/questions/3738639/sorting-a-listint –  Jun 16 '17 at 01:32
  • If you are interesting in finding "index of element in a list" you may want to consider using search engine. Since the one you usually use probably did not find anything useful you can try one provided by the same company that build C# and VS for you - https://www.bing.com/search?q=c%23+index+of+element+in+list – Alexei Levenkov Jun 16 '17 at 01:40
  • So it should be IndexOf instead of FindIndex. Thanks for the heads-up! – dozenme Jun 16 '17 at 01:48

1 Answers1

0

you can try :

List<int> members = new List<int> { 312, 33, 122, 3979, 8712, 8888 };
int a = members.IndexOf(members.Max());
DucAnhNguyen
  • 71
  • 10