コード例 #1
0
    static void VerfiyByValDateArray()
    {
        var structure1 = new StructWithDateArray()
        {
            array = new DateTime[]
            {
                DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now
            }
        };

        int    size   = Marshal.SizeOf(structure1);
        IntPtr memory = Marshal.AllocHGlobal(size);

        try
        {
            Marshal.StructureToPtr(structure1, memory, false);
        }
        finally
        {
            Marshal.FreeHGlobal(memory);
        }
    }
コード例 #2
0
ファイル: MarshalStructure.cs プロジェクト: CheneyWu/coreclr
    static void VerfiyByValDateArray()
    {
        var structure1 = new StructWithDateArray()
        {
           array = new DateTime[]
           {
                DateTime.Now, DateTime.Now , DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now , DateTime.Now, DateTime.Now
           }
        };

        int size = Marshal.SizeOf(structure1);
        IntPtr memory = Marshal.AllocHGlobal(size);
        try
        {
            Marshal.StructureToPtr(structure1, memory, false);
        }
        finally
        {
            Marshal.FreeHGlobal(memory);
        }
    }