title: QueryInterface and IntPtr in C# Syntax
body: <p>I am trying to use <code>InteropServices.Marshal.QueryInterface</code> to convert a COM object to a specific type in C#, but I am having trouble to pass in the first and last parameters.</p>
  
  <p>I am assuming that <code>IntPtr</code> is a reference, but I cannot get <code>IntPtr</code> to reference my classes to use QueryInterface due to syntax errors.</p>
  
  <p>Of course, the code that is shown below does not have the correct syntax, but it gives you an idea of what I am trying to do.</p>
  
  <pre><code>set
  {
      ClassA a;
      Guid guid = Guid.Parse("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
      System.Runtime.InteropServices.Marshal.QueryInterface(ref value, 
          ref guid, out a);
  }
  </code></pre>
  
  <p>EDIT:</p>
  
  <pre><code>[ComVisible(true), Guid("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")]
  public ClassA : COMInterface{ ... }
  </code></pre>
  
  <p>ClassA is the C# class, and <code>COMInterface</code> is the COM interface. It is the only class that implements <code>COMInterface</code>. <code>value</code> in the <code>set</code> scope is the reference to the COM Interface, <code>COMInterface</code></p>