Last active
December 16, 2016 12:01
-
-
Save mwolicki/9463f4fcd9c8dc61b4f861de3dc3a731 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainClass { | |
static void Main() { | |
System.Console.WriteLine("abcdef"); | |
Mutate("abcdef"); | |
System.Console.WriteLine("abcdef"); | |
} | |
unsafe static void Mutate(string text) { | |
var newLen = text.Length * 2; | |
fixed (char* t = text) { | |
int* len = (int*)t; | |
len--; | |
*len = newLen; | |
for (int i = 0; i < newLen; i++) | |
t[i] = 'y'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment