Exemple #1
0
        private static void TestStructExactLayout3()
        {
            ShowMarshalSize(typeof(MsEmployeeEx2_Partial2));

            // ����һ�����󣬲����Գ�ʼֵ
            MsEmployeeEx2_Partial2 employee = new MsEmployeeEx2_Partial2();
            employee.EmployeeID = 10001;
            employee.EmployedYear = 1;
            employee.CurrentLevel = 59;

            // ���ڽṹ���������󣬵��·��Ͳ���������Ľ��ṹ��ӳ�䵽�ڴ��С�
            // ��ᵼ�·��йܴ����ȡ��Ϣʧ�ܣ���������Ӧ�ó��������
            GetEmployeeInfoEx2_PartialStruct2(ref employee);

            Console.WriteLine("Ա����Ϣ:");
            Console.WriteLine("ID: {0}", employee.EmployeeID);
            Console.WriteLine("����: {0}", employee.EmployedYear);
            Console.WriteLine("ְ��: {0}", employee.CurrentLevel);
        }
Exemple #2
0
 private static extern void GetEmployeeInfoEx2_PartialStruct2(ref MsEmployeeEx2_Partial2 employee);