Has anyone ever actually used stackalloc
while programming in C#? I am aware of what is does, but the only time it shows up in my code is by accident, because Intellisense suggests it when I start typing static
, for example.
Although it is not related to the usage scenarios of stackalloc
, I actually do a considerable amount of legacy interop in my apps, so every now and then I could resort to using unsafe
code. But nevertheless I usually find ways to avoid unsafe
completely.
And since stack size for a single thread in .Net is ~1Mb (correct me if I'm wrong), I am even more reserved from using stackalloc
.
Are there some practical cases where one could say: "this is exactly the right amount of data and processing for me to go unsafe and use stackalloc
"?
System.Numbers
uses it a lot referencesource.microsoft.com/#mscorlib/system/… – Puli