Skip to content

Reverse a string

C# static method

Same task in: C#

Flowchart (ISO 5807)

StartInput sarr = s.ToCharArray()Array.Reverse(arr)Return new arrEndFigure 1 — Util.Reverse

Source code

C#
class Util {
    static string Reverse(string s) {
        var arr = s.ToCharArray();
        Array.Reverse(arr);
        return new string(arr);
    }
}

The editor opens with this code — change it and the chart redraws.

Language
C#
Constructs
static method
Topic
Classes & methods
Formats
Word, Visio, draw.io, PDF, SVG

Related examples