title: Does .NET interop copy array data back and forth, or does it pin the array?
body: <p>I have this COM method signature, declared in C#:</p>
  
  <pre><code>void Next(ref int pcch,
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)]
            char[] pchText);
  </code></pre>
  
  <p>I call it like this:</p>
  
  <pre><code>int cch = 100;
  var buff = new char[cch];
  com.Next(ref cch, buff);
  </code></pre>
  
  <p>Does the .NET interop layer first copy the whole array to a temporary unmanaged memory buffer, then copy it back? Or does the array get automatically pinned and passed by reference?</p>
  
  <p>For the sake of trying, I did this in the COM object (C++):</p>
  
  <pre><code>*pcch = 1;
  pchText[0] = L'A';
  pchText[1] = L'\x38F'; // 'Ώ'
  </code></pre>
  
  <p>I do get <code>'Ώ'</code> back when I check <code>buff[1]</code> in C# upon return. But I don't think this is a strong proof that the array gets pinned, rather than copied back and forth.</p>