title: Proper IntPtr use in C#
body: <p>I <em>think</em> I understand the use of IntPtr, though I'm really not sure. </p>
  
  <p>I copied the IDisposable pattern from MSDN just to see what I could get from it, and while I understand it for the most part, I have no idea how to implement an IntPtr properly, or even understand what it is that it's supposed to "point" to, or reference. On top of that, I have no idea how to even assign or cast an integer, string, char, double, etc. to an IntPtr to create a pointer out of it. </p>
  
  <p>Also, does IntPtr require unsafe code use? </p>
  
  <p>Anyway, here's some code just to paint a picture of what I'm talking about:</p>
  
  <pre><code>namespace Utilities
  {   
      class Disposer : IDisposable
      {
  
          private IntPtr handle;
  
          private Component component = new Component(); 
  
          private bool disposed = false;
  
          public Disposer(IntPtr handle)
          {
              this.handle = handle;
  
          }
  
          public void Dispose()
          {
              Dispose(true);
              GC.SuppressFinalize(this);
          }
  
          protected virtual void Dispose(bool disposing)
          {
              if(!this.disposed)
              {
                  if (disposing)
                  {
                      component.Dispose(); 
                  }
                  CloseHandle(handle);
  
                  handle = IntPtr.Zero;
  
                  disposed = true;
  
              }
          }
  
          [System.Runtime.InteropServices.DllImport("Kernal32")]
          private extern static Boolean CloseHandle(IntPtr handle);
      }
  
  
  
      public unsafe class ExecuteMain
      {
          Object nuller = new Object();
  
          byte boa = 0;
  
          byte *blargh = boa;
  
          public static void Main()
          { 
  
          }
      }
  }
  </code></pre>
  
  <p>Also, could someone tell me what the point of the component here is, exactly? I'm also having trouble wrapping my head around this concept as well.</p>