We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Wednesday, January 13, 2016

To print the elements in reversed order in Array in C#

    class ReverseArray
    {
        static void Main()
        {
            int[] arrays = { 1, 2, 3, 4, 5, 6 };
            int length = arrays.Length;
            int[] Reversed = new int[length];
            for (int index = 0; index < length; index++)
            {
                Reversed[length - index - 1] = arrays[index];
            }
            for (int index = 0; index < length; index++)
            {
                Console.Write(Reversed[index] + "  ");
            }
            Console.ReadLine();
        }

    }
Output:

No comments: