// Second case: Forcing the passing of an 'in' parameter to be a reference to live variable
static void PrintFirstElement(in Matrix4x4 m) => Console.WriteLine(m.M11);
static void Test() {
// Matrix4x4.Identity is a static property that returns a new Matrix4x4
PrintFirstElement(Matrix4x4.Identity); // Compiles, because the compiler creates a temporary variable on the stack that is what is referred to
PrintFirstElement(in Matrix4x4.Identity); // Fails, because we're creating a reference to something that only exists as a temporary variable
}
Code snippet taken from "Two Decades of C#: A Reference - C# 7".