Demonstrate stackalloc : StackAlloc « Development Class « C# / C Sharp






Demonstrate stackalloc

Demonstrate stackalloc
/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/


// Demonstrate stackalloc. 
 
using System; 
 
public class UseStackAlloc { 
  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]); 
  } 
}


           
       








Related examples in the same category