title: Adding String to List MVC
body: <p>Im using MVC4 Razor and I just want to ask how to create a List of string and use it in a field seperated by comma? Cause I tried something and it shows an error <code>Cannon implicitly convert type void to object</code> Ill show you my set of codes</p>
  
  <p>declared this on my header:</p>
  
  <pre><code> List&lt;string&gt; elements = new List&lt;string&gt;();
  </code></pre>
  
  <p>Then I want this <code>List&lt;string&gt; elements</code> to get populated inside a foreach loop</p>
  
  <pre><code>    &lt;tbody&gt;
              @for (var i = 0; i &lt; Model.Cards.Count; ++i)
                   {
                      var counter = i + 1;
                      &lt;tr&gt;    
                          &lt;td valign="middle"&gt; 
                              &lt;p class="small"&gt;@counter&lt;/p&gt;
                          &lt;/td&gt;
                          &lt;td valign="middle"&gt;                         
                               &lt;p class="small"&gt;@Model.Cards[i].Number.Substring(0,5)&lt;/p&gt;
                          &lt;/td&gt;
                          @elements.Add(Model.Cards[i].Number.Substring(0,5))
                     &lt;/tr&gt;
                   }
      &lt;/tbody&gt;
  </code></pre>
  
  <p>And use it in a Label</p>
  
  <pre><code>&lt;div&gt; Card Number &lt;p&gt; @String.Join(", ", elements.ToArray()) &lt;/p&gt;&lt;/div&gt;
  </code></pre>