There is an option in C# to execute code unchecked. It's generally not advised to do so, as managed code is much safer and it overcomes a lot of problems.
However I am wondering, if you're sure your code won't cause errors, and you know how to handle memory then why (if you like fast code) follow the general advice?
I am wondering this since I wrote a program for a video camera, which required some extremely fast bitmap manipulation. I made some fast graphical algorithms myself, and they work excellent on the bitmaps using unmanaged code.
Now I wonder in general, if you're sure you don't have memory leaks, or risks of crashes, why not use unmanaged code more often?
PS my background: I kinda rolled into this programming world and I work alone (I do so for a few years) and so I hope this software design question isn't that strange. I don't really have other people out there like a teacher to ask such things.
unsafemeans "know what you're doing, and weigh the benefits against the risks." I've usedunsafea handful of times, and it was always for something very specific related to performance that could be walled off in its own method. I don't use it as a general programming technique, since most of the time the additional performance benefit is not worth the loss in safety.unsafeuse-case example: stackoverflow.com/q/11660127/102937