Introduction
In this article, we are going to explore how to reverse the order of the given string.
Eg.
- Input: This is Kirtesh Shah
- Result: Shah Kirtesh is This
This is an essential technical interview question that may be posed to beginner, intermediate, and experienced candidates.
We previously covered,
- How to Reverse Number in C#
- How to Reverse a String in C#
- Palindrome String Program in C#
- Palindrome Number in C#
Let’s start,
Reverse order of the given string.
First, create the Asp.Net Core Console application and write the below code in the program.cs file.
Console.WriteLine("Enter a string");
var str = Console.ReadLine();
var strArray = str.Split(" ").Reverse();
var reverseOrder = String.Join(" ", strArray);
Console.WriteLine($"{reverseOrder}");
Console.ReadLine();
Output
That’s all for this article. Hope you enjoy this article and learn something new.