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:
Related in same category :
-
-
-
-
-
|