Esempio n. 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);
        }
    }
Esempio n. 2
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);
        }
    }