Marshal.AllocCoTaskMem : Marshal « System.Runtime.InteropServices « C# / C Sharp by API






Marshal.AllocCoTaskMem

  

using System;
using System.Runtime.InteropServices;

class MainClass
{
  static void Main(string[] args)
  {
    UsePointers();
  }
  static unsafe public void UsePointers()
  {
    char * pMyArray = (char*)Marshal.AllocCoTaskMem(6);

    while (*pMyArray != '\0')
    {
      Console.WriteLine(*pMyArray);
      pMyArray++;
    }

    Marshal.FreeCoTaskMem((IntPtr)pMyArray);
  }
}

   
    
  








Related examples in the same category

1.Marshal.AllocHGlobal
2.Marshal.FreeHGlobal
3.Marshal.StringToCoTaskMemAnsi