Demonstrate stackalloc : Memory : Windows C# Examples


C# Examples » Windows » Memory »

 

Demonstrate stackalloc









    
using  System;  
  
class  MainClass  {  
    unsafe  public  static  void  Main()  {  
        int*  ptrs  =  stackalloc  int[3];  
  
        ptrs[0]  =  1;  
        ptrs[1]  =  2;  
        ptrs[2]  =  3;  
  
        for(int  i=0;  i  <  3;  i++)  
            Console.WriteLine(ptrs[i]);  
    }  
}
    
   
  
   



Output

1
2
3


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Windows
» Memory