Allocate and free memory : Memory : Windows C# Examples


C# Examples » Windows » Memory »

 

Allocate and free memory









    
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);
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Windows
» Memory