You have written the C# code snippet given below.
int len = 5; Span<int> num = stackalloc int[len]; for (var i = 0; i < len; i++) { num[i] = i; }
In this context, which of the following statements related to the stackalloc expression used stands TRUE?
1.The stack allocated memory block created during the method execution will continue to stay alive even after the method returns.
2.The stack allocated memory block created during the method execution will automatically be discarded when that method returns.
3.You cannot explicitly free the memory allocated with stackalloc.
4.You can explicitly free the memory allocated with stackalloc.
Options
- Only 1
- Only 3
- Only 2 and 3
- Only 1 and 4