
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
C# program to reverse an array
Firstly, set the original array −
int[] arr = { 15, 16, 17, 18 }; // Original Array Console.WriteLine("Original Array= "); foreach (int i in arr) { Console.WriteLine(i); }
Now, use the Array.reverse() method to reverse the array −
Array.Reverse(arr);
Example
The following is the complete code to reverse an array in C#
using System; class Demo { static void Main() { int[] arr = { 15, 16, 17, 18 }; // Original Array Console.WriteLine("Original Array= "); foreach (int i in arr) { Console.WriteLine(i); } // Reverse Array Array.Reverse(arr); Console.WriteLine("Reversed Array= "); foreach (int j in arr) { Console.WriteLine(j); } Console.ReadLine(); } }
Output
Original Array= 15 16 17 18 Reversed Array= 18 17 16 15
- Related Articles
- C program to reverse an array elements
- C++ program to reverse an array elements (in place)
- Java program to reverse an array
- Write a program to reverse an array or string in C++
- C Program to Reverse Array of Strings
- Write a C program to reverse array
- Write a Golang program to reverse an array
- Reverse an array using C#
- Reverse an array in C++
- Write a program to reverse an array in JavaScript?
- Java program to reverse an array upto a given position
- How to reverse an Array using STL in C++?
- Java program to reverse an array in groups of given size
- Python program to reverse an array in groups of given size?
- Program to reverse an array up to a given position in Python

Advertisements