static void DemoStructMarshallingByRef() { var time = new SystemTimeStruct(); GetSystemTime(out time); Console.WriteLine($"The time is {time}"); }
static void DemoStructMarshallingByValue() { var time = new SystemTimeStruct(); GetSystemTime(time); // the changes won't be reflected because the struct is passed by value Console.WriteLine($"The time is {time}"); }
static extern void GetSystemTime(out SystemTimeStruct time); // would also work with ref
static extern void GetSystemTime(SystemTimeStruct time); // this won't work because GetSystemTime requires an argument that can be copied out (i.e. at least an out variable)