Allocating Memory from the Stack : stackalloc : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » stackalloc »

 

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]);
    }
}
           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» stackalloc