In this C# tutorial, I will explain, how to reverse an array in C# with 4 different methods.
Reverse an Array in C#
There are 4 different ways methods to reverse an array in C#.
- Using Array.Reverse Method
- Using a Loop
- Using Linq
- Using Stack
1. Using Array.Reverse Method
This is the simplest and most straightforward way to reverse an array in C#.
using System;
namespace ReverseArrayExample
{
class Program
{
static void Main()
{
string[] cities = { "New York", "Los Angeles", "Chicago", "Houston", "Phoenix" };
Array.Reverse(cities);
foreach (var city in cities)
{
Console.WriteLine(city);
}
}
}
}
Output:
Phoenix
Houston
Chicago
Los Angeles
New York
You can follow the screenshot below:

2. Using a Loop
Another method is to manually reverse the array by swapping elements using a loop in C#. Below is the complete code to reverse the array in c# using for loop.
using System;
namespace ReverseArrayExample
{
class Program
{
static void Main()
{
string[] cities = { "New York", "Los Angeles", "Chicago", "Houston", "Phoenix" };
int len = cities.Length;
for (int i = 0; i < len / 2; i++)
{
string temp = cities[i];
cities[i] = cities[len - 1 - i];
cities[len - 1 - i] = temp;
}
foreach (var city in cities)
{
Console.WriteLine(city);
}
}
}
}
This is how to reverse array in c# using for loop.
3. Using Linq
For those who prefer functional programming or LINQ style methods, this is an elegant way to reverse an array in C#.
using System;
using System.Linq;
namespace ReverseArrayExample
{
class Program
{
static void Main()
{
string[] cities = { "New York", "Los Angeles", "Chicago", "Houston", "Phoenix" };
cities = cities.Reverse().ToArray();
foreach (var city in cities)
{
Console.WriteLine(city);
}
}
}
}
4. Using Stack
The nature of the stack is “Last In, First Out” (LIFO). We can utilize this feature to reverse an array in C#.
using System;
using System.Collections.Generic;
namespace ReverseArrayExample
{
class Program
{
static void Main()
{
string[] cities = { "New York", "Los Angeles", "Chicago", "Houston", "Phoenix" };
Stack<string> stack = new Stack<string>(cities);
cities = stack.ToArray();
foreach (var city in cities)
{
Console.WriteLine(city);
}
}
}
}
You can check the output below:

These are the 4 methods you can use to reverse an array in C#.
Conclusion
Reversing an array in C# can be achieved in multiple ways, each with its own use cases and advantages. Whether you’re looking for a straightforward method using built-in libraries, a functional approach with LINQ, or a hands-on approach with loops or stacks, C# provides the tools you need. I hope you got a complete idea of how to reverse an array in C#.
You may also like:
- How to Check if an Array is Empty in C#?
- How to Reverse an Array in C# Without Using Reverse Function?
- C# String Array Contains Multiple Values
- Compare String Value with String Array in C#
Bijay Kumar is a renowned software engineer, accomplished author, and distinguished Microsoft Most Valuable Professional (MVP) specializing in SharePoint. With a rich professional background spanning over 15 years, Bijay has established himself as an authority in the field of information technology. He possesses unparalleled expertise in multiple programming languages and technologies such as ASP.NET, ASP.NET MVC, C#.NET, and SharePoint, which has enabled him to develop innovative and cutting-edge solutions for clients across the globe. Read more…