Skip to content

Instantly share code, notes, and snippets.

@aevitas
Created March 10, 2020 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aevitas/53c71887f8b447bceba68a8b2775f9ea to your computer and use it in GitHub Desktop.
Save aevitas/53c71887f8b447bceba68a8b2775f9ea to your computer and use it in GitHub Desktop.
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