>>>' Reverse the input string, without using the StrRever function in the VB6 >>>' compatibility assembly >>>Function ReverseString(String source) As String >>> Dim chars() As Char = source.ToCharArray() >>> Array.Reverse(chars) >>> Return New String(chars) >>>End Function >>>>>>Unfortunately it is VB.NET not C#. Main goal here is to convert whole string to array and then Reverse the array and return converted array back to string :-) I hope NET gurus will give you more beautiful solution.
>>using System; >> >>class sample >>{ >> static void Main() >> { >> Console.WriteLine("Write text to reverse and press [enter]"); >> string inputStr = Console.ReadLine(); >> Console.WriteLine( ReverseString( inputStr ) ); >> } >> >> public static string ReverseString(string source) >> { >> char[] aStr = source.ToCharArray(); >> Array.Reverse(aStr); >> return new String( aStr ); >> } >>} >>If you have .net 2.0 SDK, go to command prompt, write this with notepad to a .cs file, compile using "csc.exe".
public string ReverseString( char* source ) { char reversed[] = source; for(int i=0;i<strlength(source);i++); { *(reversed--) = *(source++); } return reversed; }PS: Untested. But should be like this as I remember core C.