title: C# MVC3 Razor alternating items in a @foreach list?
body: <p>In MVC3, how do you create alternating row colors on a @foreach list when using the Razor view engine?</p>
  
  <pre><code>@foreach (var item in Model) {    
      &lt;tr&gt;
          &lt;td&gt;@item.DisplayName&lt;/td&gt;
          &lt;td&gt;@item.Currency&lt;/td&gt;
          &lt;td&gt;@String.Format("{0:dd/MM/yyyy}", item.CreatedOn)&lt;/td&gt;
          &lt;td&gt;@String.Format("{0:g}", item.CreatedBy)&lt;/td&gt;
          &lt;td&gt;@Html.ActionLink("Edit", "Edit", new { id = item.Id })&lt;/td&gt;
      &lt;/tr&gt;
  }
  </code></pre>