unsafe
{
long* a;
int* a1 = stackalloc int[5];
a1[0] = 1;
a1[1] = 2;
a1[2] = 3;
a1[3] = 4;
a1[4] = 5;
a = (long*)a1;
Console.WriteLine(*a);
for (int i = 0; i < 2; i++)
{
Console.WriteLine(*(a + i));
Console.WriteLine(*(a1 + i));
}
int[] b1 = { 10, 11, 12, 13, 14 };
fixed (int* bb = &b1[0])
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine(*(bb + i));
}
}
}
转载于:https://www.cnblogs.com/niezl/p/5881724.html