Write a program to reverse the array in C#

 Solution 1:

// C# code for the approach

using System;

class GFG {
    // Driver Code
    static void Main()
    {
        // Input array
        int[] arr = { 1, 423, 6, 46, 34, 23, 13, 53, 4 };
        int length = arr.Length;
         int[] revArr = new int[length];
         for (int i = 0; i < length; i++)
             {
                 revArr[length - i -1] = arr[i];               
             }

         Console.WriteLine("Reverse array: " + revArr);
         Console.ReadKey();
        
    }
}


Output
arr = { 4,53,13,23,34,46,6,423,1};

Comments

Popular posts from this blog

Input = INDIA, count each char in input string