TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Display a String in Reverse Using Recursion in C#
Saurabh Sarkar
Jul 11
2016
Code
13.2
k
0
2
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
using
System;
namespace
Reverse
{
class
Program
{
public
static
void
Main()
{
string
str =
"this is a test"
;
Reverse rsObj =
new
Reverse();
Console.WriteLine(
"Original string: "
+ str);
Console.Write(
"Reversed string: "
);
rsObj.displayReverse(str);
Console.ReadKey();
}
}
class
Reverse
{
public
void
displayReverse(
string
str)
{
if
(str.Length > 0)
displayReverse(str.Substring(1, str.Length - 1));
else
return
;
Console.Write(str[0]);
}
}
}
C#
Recursion Method
Reverse string