How to reverse string without using Reverse() in C# - Programming for Beginners

Reverse string without using any C# function

Recently in one of the interviews I was asked to reverse the string without using Reverse() in .Net. Below is the simple code to demonstrate how to reverse the string with a simple for each loop.

        string strValue = "Interview question for beginner!";
        string reverseValue = string.Empty;
        foreach (char c in strValue)
            reverseValue = c + reverseValue; // concantenate the characters in a reverse mode



c string,without using,reverse(),programming code,learn C#

1 comment:

  1. The result is ok.
    But why does it reads strValue variable's value in reverse mode? Does foreach () loop reads a string in reverse direction?


All Rights Reserved by Etechpulse © 2015 - 2016
Powered By Blogger

Contact Form


Email *

Message *

Powered by Blogger.