strReverse in C#

dynamic_sysop

Senior Contributor
Joined
Oct 1, 2002
Messages
1,039
Location
Ashby, Leicestershire.
no demo project need for this as it's only a few lines of code , anyway it's a little code i knocked together to reverse strings in C# ( reversed in the same way as strReverse in Vb did ) ...
C#:
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show(StringReverse("test 123"));
}

private string StringReverse(string ToReverse)
{
Array arr = ToReverse.ToCharArray();
Array.Reverse( arr );// reverse the string
char[] c = (char[])arr;
byte[] b = System.Text.Encoding.Default.GetBytes(c);
return System.Text.Encoding.Default.GetString(b);
}
 
Last edited by a moderator:
Back
Top