using System;
class Test {
public static unsafe String UnsafeCodeExample( String s ) {
int strLength = s.Length;
char[] str = new char[strLength+1];
string strReturn = "";
fixed(char* strPointer = str) {
for ( int i=0; i<strLength; ++i )
strReturn += strPointer[i];
}
return strReturn;
}
public static void Main() {
String s = UnsafeCodeExample("This is a test");
Console.WriteLine( "Reversed: {0}", s );
}
}
|