Valerie Meunier

Valerie Meunier

  • NA
  • 693
  • 82.7k

reverse an array

Aug 25 2021 9:40 PM

Hi

I try to reverse sort values in an array, but this code doesn't work. No error, but this is what i get: 4 85 6 99 etc ...

What's wrong with my code?

Thanks

public static void Main()
    {
        int[] array = { 2, 11, 15, 1, 7, 99, 6, 85, 4 };
        Array.Reverse(array); // Reverse Sorting array value  
        foreach (var result in array)
        {
            Console.Write(result + " "); // Array values   
        }

    }


Answers (7)