Beispiel #1
0
        static void DemoStructMarshallingByRef()
        {
            var time = new SystemTimeStruct();

            GetSystemTime(out time);
            Console.WriteLine($"The time is {time}");
        }
Beispiel #2
0
        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}");
        }
Beispiel #3
0
 static extern void GetSystemTime(out SystemTimeStruct time);    // would also work with ref
Beispiel #4
0
 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)