Why doesn't *(int*)0=0 cause an access violation?
问题 For educational purposes, I'm writing a set of methods that cause runtime exceptions in C# to understand what all the exceptions are and what causes them. Right now, I'm tinkering with programs that cause an AccessViolationException . The most obvious way (to me) to do this was to write to a protected memory location, like this: System.Runtime.InteropServices.Marshal.WriteInt32(IntPtr.Zero, 0); Just as I had hoped, this threw an AccessViolationException . I wanted to do it more concisely, so