private static void TestStructArgumentVal() { ManagedSimpleStruct simpleStruct = new ManagedSimpleStruct(); simpleStruct.intValue = 10; simpleStruct.shortValue = 20; simpleStruct.floatValue = 3.5f; simpleStruct.doubleValue = 6.8f; TestStructArgumentByVal(simpleStruct); Console.WriteLine("\n�ṹ�������ݣ�int = {0}, short = {1}, float = {2:f6}, double = {3:f6}", simpleStruct.intValue, simpleStruct.shortValue, simpleStruct.floatValue, simpleStruct.doubleValue); }
private static void TestCorrectPack() { Console.WriteLine("�йܴ��붨��Ľṹ���ڷ��йܴ����еĴ�СΪ��{0}�ֽ�", Marshal.SizeOf(typeof(ManagedSimpleStruct))); ManagedSimpleStruct argStruct = new ManagedSimpleStruct(); argStruct.intValue = 1; argStruct.shortValue = 2; argStruct.floatValue = 3.0f; argStruct.doubleValue = 4.5f; TestStructArgumentByRef(ref argStruct); Console.WriteLine("\n�ṹ�������ݣ�int = {0}, short = {1}, float = {2:f6}, double = {3:f6}", argStruct.intValue, argStruct.shortValue, argStruct.floatValue, argStruct.doubleValue); }
private static extern void TestStructArgumentByVal(ManagedSimpleStruct argStruct);