DotNet Mirror
  DNM facebook   DNM Google+   DNM Twitter   

Reverse string without using any built in function in .NET

By Ashok Nalam on 12 Dec 2012 | Category: C# | Tagged: string 
In this snippet we will see how to reverse a string easily without using any built function or string function
  Discuss Add Comment   |  
Add rating Rate this resource   
In many of interviews, interviewers will ask write a program to reverse a string without using any built function. So in this snippet we will see how to reverse a string easily without using any built function or string function.

String Reverse Program:

class StringReverseProgram
{
static void Main(string[] args)
{
string normalStr = "This is DotNetMirror";
string reverseStr = string.Empty;
foreach (char chr in normalStr)
{
reverseStr = chr + reverseStr;
}
Console.WriteLine(reverseStr); //Output : rorriMteNtoD si sihT
Console.ReadKey();
}
}

Output:

rorriMteNtoD si sihT

  Discuss Add Comment    
Add rating Rate this resource   
About the Contributor
Member Since : 10 Dec 2012
Member Points (Level) : 8666  (Professional)
Location : INDIA
Home Page : http://dotnetmirror.com
About : I am admin of this site.
Rate this resource
 
Add your Comment
Name Email WebSite
Captcha Refresh


Comments (0)
No comments found, click here to add comment.