Writing unsafe code
A word of warning before we start talking about unsafe code. There is a reason it is called “unsafe.” You could be in for much trouble when you leave safe code.
The CLR checks many things for you when you run your code. For instance, it ensures type safety and ensures you are not playing around with spaces in memory that are not yours to play with.
In the “old” days, when using C++ or C in Windows development, this was the primary source of program crashes. Developers made a slight mistake in their pointer arithmetic and ended up reading or writing memory they had no access to. The operating system immediately killed your process, and you got that dreaded AccessViolationException
error. This is the ultimate slap on the wrist: the operating system telling you to stay out of someone else’s memory. Sometimes, it would be worse: the operating system might not have caught it, and you messed up the operating system or another program...