title: asp.net mvc razor foreach loop adding id to div
body: <p>I am trying to add dynamic <code>id</code> to <code>div</code> inside a <code>foreach</code> loop concatenated with value of variable <code>i</code>. It throws syntax errors. What might be the issue. Can we achieve this solution without using a <code>for</code> loop ?</p>
  
  <pre><code>@{int i=1;}
  @foreach (var or in Model.Names)
  {           
         &lt;div oid="@or.Id" mode="0" oids="@or.Id" id="tr"+i&gt;
         @or.Name
         &lt;/div&gt;
  i++;
  }
  </code></pre>