title: How would I populate a vector with all the elements from a List of type system string while converting it to std::string?
body: <p>I am trying to understand lambda functions better and would like some example of how I could add to a vector while converting System.String^ to std::string with such a Lambda example (If I am able to).</p>
  
  <p>My current foreach: </p>
  
  <pre><code>List&lt;String^&gt;^ names = //Returning 'System.String' List from C#
  
      for each (System::String^ name in names)
      {
        std::string convertedString = msclr::interop::marshal_as&lt; std::string &gt;(name);
        nameObjects.push_back(MyObject(convertedString, "test"));
      }
  </code></pre>
  
  <p>But I would like to extend it to something like this (<em>My best guess but I am missing the logic to convert each element of "names" to a single string, this is where a Lambda would help me</em>): </p>
  
  <pre><code>    std::vector&lt;nameObjects&gt; testObjects{ std::begin(msclr::interop::marshal_as&lt; std::string &gt;(names)), std::end(msclr::interop::marshal_as&lt; std::string &gt;(names)) };
  </code></pre>