Hellow Friends,
Now I am going to describe how to reverse a string with using recursion function.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace recersfunction
{
class recursionstring
{
public void reversestring(string str)
{
if(str.Length > 0)
reversestring(str.Substring(1, str.Length-1));
else
return;
}
}
class program {
static void Main(string[] args)
{
string str, Revstr = "";
int length;
Console.Write("Please Enter Your string : ");
str = Console.ReadLine();
length = str.Length - 1;
while (length >= 0)
{
Revstr = Revstr + str[length];
length--;
}
Console.WriteLine("Your revrse string value is {0}", Revstr);
recursionstring obj = new recursionstring();
obj.reversestring(str);
Console.ReadLine();
}
}
}
I have explained reverse a string using recursion function.
So after read please Comments and
suggestions.
Thanks & Regard
Rabi
No comments:
Post a Comment