Public feed
#600722
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct Point
{
int X;
int Y;
}
static unsafe void Main(string[] args)
{
Point[] points = new Point[4];
int[] intArr = new int[8];
int* nextIntPtr;
intArr[0] = 5;
intArr[1] = 3;
intArr[2] = 5;
intArr[3] = 3;
intArr[4] = 5;
intArr[5] = 3;
intArr[6] = 5;
intArr[7] = 3;
fixed(int* intArrPtr = intArr)
{
nextIntPtr = intArrPtr;
for(int i = 0; i < 4; i++)
{
points[i] = *(Point*)nextIntPtr;
nextIntPtr += 8;
Console.WriteLine("Size of struct #{0}: {1}", i.ToString(), Marshal.SizeOf(points[i]).ToString());
}
}
Console.ReadLine();
}
}
}