C# / .NET - how to reverse a string

0 points
Created by:
Dirask Admin - Marvin

In this article, we would like to show you how to reverse a string in C#.

Practical example

In the example below, we use the Array.Reverse() method, which argument is a string converted into an array of characters.

using System;

public class Program
    static string ReverseString(string originalString)
        char[] charArray = originalString.ToCharArray();
        return new string(charArray);

    public static void Main(string[] args)
        string originalString = "This is your text...";

        string reversedString = ReverseString(originalString);
        Console.WriteLine(reversedString); // ...txet ruoy si sihT


...txet ym si sihT

C# / .NET - String (popular problems)

Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂