Created
March 10, 2020 14:05
-
-
Save aevitas/53c71887f8b447bceba68a8b2775f9ea 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
static void Main(string[] args) | |
{ | |
var vec = new Vector3 {X = 10, Y = 20, Z = 30}; | |
Foo(ref vec); | |
} | |
public static unsafe void Foo(ref Vector3 vec) | |
{ | |
fixed (Vector3* ptr = &vec) | |
{ | |
Console.WriteLine($"{ptr->X += 10}, {ptr->Y += 10}, {ptr->Z += 10}"); | |
} | |
} | |
public ref struct Vector3 | |
{ | |
public float X; | |
public float Y; | |
public float Z; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment