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

Recommended Answers

All 3 Replies

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

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);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.