Manish Tewatia

Manish Tewatia

  • 20
  • 48.2k
  • 3.3m

How to use stackalloc?

Apr 12 2011 1:52 AM
Is this code is correct, I want to allocate memory from the stack..

using System;
using System.Globalization;

public class ABC{

 static void Main(string[] args)
 {
 
 unsafe 
 {
 char* i = stackalloc[256];
 for (int j = 0; j < 256; j++) 
 i[j] = (char)j;
 
 }
}

Answers (1)