C# Program for Reverse a String

This blog defines how to reverse a string using C# program.

using System;
using
System.Collections.Generic;
using
System.Text;
using
System.Linq;

namespace
reversestring
{
    class programme
    {
        static void Main(string[] args)
        {
           char strO[30] , strR[30];
           int  i=0,len,j;
           console.writeline("enter a string");
           strO = console.readlinr();
           len = strlen(strO);
           console.writeline("reverse string");
           for(i=0,j=len-1; i<len,j>=0; i++,j--)
           strR[j] = strO[i];
           strR = '\0';
           console.writelin("reverse string is {0}", strR);
        }
    }
}

Ebook Download
View all
Learn
View all