方式一:使用 stackalloc 关键字

int* block = stackalloc int[100];  

注:以下代码导致编译器错误。
int* block;  
// The following assignment statement causes compiler errors. You  
// can use stackalloc only when declaring and initializing a local   
// variable.  
block = stackalloc int[100];  

IntPtr hglobal = Marshal.AllocHGlobal(100);
Marshal.FreeHGlobal(hglobal);
 

相关文章:

  • 2021-07-23
  • 2021-09-26
  • 2022-01-11
  • 2021-05-28
  • 2022-02-09
  • 2022-01-15
  • 2021-08-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
  • 2021-05-15
  • 2022-12-23
相关资源
相似解决方案