Reverse a String with substring method - CSharp System

CSharp examples for System:String SubString

Description

Reverse a String with substring method

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Globalization;
using System.Collections.Generic;
using System;/* w ww  .ja  va  2  s.c  om*/

public class Main{
        public static string Reverse(string input)
        {
            string ret = "";
            for (int i = input.Length - 1; i >= 0; i--)
            {
                ret += input.Substring(i, 1);
            }
            return ret;
        }
}

Related Tutorials