title: Convert array<String^>^ to std::vector<std::string>
body: <p>How can I convert a managed <code>array&lt;String^&gt;^</code> to <code>std::vector&lt;std::string&gt;</code>. The following code doesnt compile and I can't figure out why. Funny enough, if I use an int for example then it works fine. thanks in advance:</p>
  
  <pre><code>std::vector&lt;std::string&gt; ConvertToUnManaged(array&lt;String^&gt;^ ar)
  {
      using System::IntPtr;
      using System::Runtime::InteropServices::Marshal;
  
      std::vector&lt;std::string&gt; vector(ar-&gt;Length);
      Marshal::Copy(ar, 0, IntPtr(&amp;vector[0]), ar-&gt;Length);
  
      return vector;
  }
  </code></pre>