When would I need to use the stackalloc keyword in C#?
问题 What functionality does the stackalloc keyword provide? When and Why would I want to use it? 回答1: From MSDN: Used in an unsafe code context to allocate a block of memory on the stack. One of the main features of C# is that you do not normally need to access memory directly, as you would do in C/C++ using malloc or new . However, if you really want to explicitly allocate some memory you can, but C# considers this "unsafe", so you can only do it if you compile with the unsafe setting.