Allocating Memory from the Stack : Unsafe Code « Language Basics « C# / C Sharp
- C# / C Sharp
- Language Basics
- Unsafe Code
Allocating Memory from the Stack
using System;
public class MyClass
{
public unsafe static void Main()
{
int * buf = stackalloc int [5];
for(int i = 0; i < 5; i++)
buf[i] = i;
for(int i = 0; i < 5; i++)
Console.WriteLine(buf[i]);
}
}
Related examples in the same category