title: What to pass for pinned string in P/Invoke?
body: <p>Assume this C function:</p>
  
  <pre><code>void do_something(const char* str)
  </code></pre>
  
  <p>It stores the string somewhere for <em>later reference</em>.</p>
  
  <p>Furthermore, I have this signature in C# to call this function:</p>
  
  <pre><code>[DllImport("NativeLib")]
  static extern void do_something(string str);
  </code></pre>
  
  <p>Now, what do I need to do when passing a string to this method:</p>
  
  <ul>
  <li>Do I need to pin the string (with <code>GCHandle.Alloc()</code>) (or is the marshaller creating a copy)?</li>
  <li>If I do need to pin it, do I pass the "original" string (i.e. the string I passed to <code>GCHandle.Alloc()</code>)? Or do I need to pass the return value of <code>GCHandle.AddrOfPinnedObject()</code>?</li>
  <li>Is <code>string</code> the correct data type (for <code>do_something</code>) in this case? Or should I use <code>IntPtr</code> instead?</li>
  </ul>