0

Hey all,

I have an assignment which has a part in which i have to reverse a given string. Can any one tell me any code snippets which will reverse the string automatically or refer any built-in function.

Thanks in advance

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by abelLazm
0

Thank you so much abellazm this is really helpful. One more question isn't there any built-in function for this purpose?

0

You are welcome ... the shortest way to do this is to convert the string into character array and then reverse it

private static string ReverseString(string input)
{
	char[] inputChars = input.ToCharArray();
	Array.Reverse(inputChars);
	return new string(inputChars);
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.