How to use a fixed statement
This article introduces the knowledge of "how to use fixed statements". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The variable in the fixed statement is a read-only variable. If you need to modify the value of this variable, redeclare a pointer variable, and then modify the corresponding value of the variable. If you want to allocate memory in the fixed statement, it will not be affected by GC. Use stackalloc expressions (see https://docs.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/stackalloc for stackalloc expressions
The stackalloc expression allocates blocks of memory on the stack. Memory allocated using stackalloc cannot be explicitly freed, and memory blocks allocated in the stack are not affected by GC and do not need to be fixed by fixed statements. Stackalloc can be used for system.Span ReadOnlySpan or pointer types. For pointer types, they can only be used in the context of unsafe. Span does not need it, and it is officially recommended to use Span instead of pointer types.
Unsafe
{
Int length=3
Int* numbers = stackallock int [length]
For (var iTuno Bandi)