Get benefited from interview Q/A and Online Test section. Subscribe to this blog to get updates directly in your mail box.
Best View in Google Crome, Mozilla firefox or IE 7 or above

Sunday, June 26, 2011

String Reverse with X in between each character in C Sharp Dotnet

Here is a C# Interview question I faced in an interview. This is very easy. But, I am sharing just to make all of you aware of this type of questions being asked in interviews.


Write a function named XReverse in C# that will take a string as input and return the reverse of the string with 'X' in between each characters as Output.

Solution Code:

public static string xReverse(string inputStr)
            int len = inputStr.Length;
            StringBuilder revStr = new StringBuilder();

            for (int i = len - 1; i >= 0; i--)
                if (i != 0)
            return revStr.ToString();


If anybody has any other solution or has a better idea, please share as comments.

1 comment:

  1. Same question is been asked by ITC infotech last week


  © Blogger templates Shiny by 2008

Back to TOP