Array.Max (); for array index, not value

I am creating an array that will contain 24 numbers and display them in a table. I used "arrayname" .Max (); to determine the largest number, but I need to display the array slot with the highest number

eg. hour 15 had the largest number, so the message will display 15, not the number assigned to 15.

My code is as follows:

 public void busiest(int[] A)
 {
     int busy;
     busy = A.Max(); //Displays the highest values in a given set i.e. an array
     Console.WriteLine("\nThe busiest time of day was hour " + busy);
 }

Can someone tell if I am missing something simple to display the slot, and not the assigned number?

thank

+4
source share
1 answer

To call you need Array.IndexOf:

Array.IndexOf(A, A.Max());

For more information about this method, please see here .

, , . , 10 2 3, 2.

+7

Source: https://habr.com/ru/post/1694000/


All Articles