title: Add Item To String Array In Razor View
body: <p>I have a razor view where I am declaring a string array</p>
  
  <pre><code>@{
    var siteList = new List&lt;string&gt;();
    var stockTypeList = new List&lt;string&gt;();
  }
  </code></pre>
  
  <p>There is an event on a multiselect that iterates over the selected values and I want to add the value of each of the selected items to this array</p>
  
  <pre><code>$('#stockTypeArea select :selected').each(function (i, selected) {
    @stockTypeList.Add(selected.val());
  });
  </code></pre>
  
  <p>Currently this complains that it cannot resolve the 'selected' value. So my question is how can I add these string values to my string array?</p>
  
  <p>The reason I need the string array is that I post this back as part of a @Html.Action</p>
  
  <pre><code>@HTML.Action("CustomReport_Data", "Reports", new { stockCodesList = stockTypeList })))
  </code></pre>
  
  <p>Perhaps there is a better way to capture this list of strings and pass back to the controller.</p>
  
  <p>Even when I try and test the add method to my string array with:</p>
  
  <pre><code>@stockTypeList.Add("Test");
  </code></pre>
  
  <p>I get an error that:</p>
  
  <pre><code>Expression must return a value to render
  </code></pre>