Last active
September 14, 2017 11:58
-
-
Save mwolicki/71eb5ebab3a591c1e8b5d1f0fb53cedd 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 () { | |
var text = "abcdef"; | |
System.Console.WriteLine (text); | |
Mutate (text); | |
System.Console.WriteLine (text); | |
} | |
unsafe static void Mutate (string text) { | |
fixed (char* t = text) | |
for (int i = 0; i < text.Length; i++) | |
t[i] = 'z'; | |
} | |
} |
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
#nowarn "9" | |
let mutate (txt:string) : unit = | |
use ch = fixed txt | |
for i = 0 to txt.Length - 1 do | |
Microsoft.FSharp.NativeInterop.NativePtr.set ch i 'z' | |
let text = "abcd" | |
printfn "%s" text | |
mutate text | |
printfn "%s" text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment