Please look at this code....
Code:
using System;
public class Bar
{
public static void Main()
{
int[] a = {5, 4, 3, 2, 1};
unsafe
{
fixed(int* ptr = a)
{
int* reader = ptr;
while(true)
{
Console.Write("@ 0xX{0:X}is ", (uint)reader);
Console.WriteLine("{0}", *(reader--));
}
}
}
}
}
This code didn't throw an exception (which I expected), but the program just terminates at some point... Btw, if I modify it and replace int[] a with int a (and make the pointer point to variable a), it'll work as expected (it'll throw an exception).
What do you guys think?