title: Return SAFEARRAY from c++ to c#
body: <p>I have a c++ method which creates, fills and returns SAFEARRAY:</p>
  
  <pre><code>SAFEARRAY* TestClass::GetResult(long&amp; size) 
  {
      return GetSafeArrayList(size);
  }
  
  How should I export that function in a DLL so that c# could take it
  How should I write c# method signature?
  </code></pre>
  
  <p>I have in c++ something along these lines:</p>
  
  <pre><code>extern "C" __declspec(dllexport) void GetResult(SAFEARRAY*&amp; data, long&amp; size)
  {
      size = 0;
      data = handle-&gt;GetResult(size);
  }
  </code></pre>
  
  <p>Is it correct, isn't it?</p>
  
  <p>Thanks for help!</p>
  
  <p>EDIT:</p>
  
  <p>c# call:</p>
  
  <pre><code>public static extern void GetResult(IntPtr handle, [MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_USERDEFINED)] TestStruct[] data, ref int size);
  </code></pre>