title: How can we declare local variable and output its value?
body: <p>I have declared a variable like this</p>
  
  <pre><code>@{ int i = 1; }
  </code></pre>
  
  <p>Now, inside <code>foreach</code> loop i want to assign the value of i each time the loop is processed;</p>
  
  <pre><code> @foreach (var line in Model.Cart.Lines)
   {
        &lt;input type="hidden" name="item_name_@i" value="@line.Product.ProductName" /&gt;
        &lt;input type="hidden" name="amount_@i" value="@line.Product.Price" /&gt;
        &lt;input type="hidden" name="quantity_@i" value="@line.Quantity" /&gt;
        @i++;
   }
  </code></pre>
  
  <p>but it isn't working. </p>
  
  <p>Any solution?</p>