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






Marshal.FreeHGlobal

  
using System;
using System.IO;
using System.Reflection;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;

public class MainClass
{
    public static void Main()
    {
        IntPtr ptr = Marshal.AllocHGlobal(1024);

        if (ptr != IntPtr.Zero){
                Marshal.FreeHGlobal(ptr);
                ptr = IntPtr.Zero;
        }
    }
}   

   
    
  








Related examples in the same category

1.Marshal.AllocCoTaskMem
2.Marshal.AllocHGlobal
3.Marshal.StringToCoTaskMemAnsi