title: Conditional css class with if in razor
body: <p>Hi i have question about Razor.</p>
  
  <p>I want to conditional class using <code>if</code> statment but i have a weird result, let me show:</p>
  
  <pre><code>@{ var row_odd = false; }
  @for (int y = 0; y &lt;= Model.Count() - 1; y++)
  {
      &lt;div class='at-column-item @if (row_odd) { @("at-column-item-odd") }'&gt;@row_odd&lt;/div&gt;
      row_odd = !row_odd;
  }
  </code></pre>
  
  <p>If i run this code i always have the <code>at-column-item-odd</code> inserted in all the divs.</p>
  
  <p>But if I use this code i have the rigth result:</p>
  
  <pre><code>@{ var row_odd = false; }
  @for (int y = 0; y &lt;= Model.Count() - 1; y++)
  {
      &lt;div class='at-column-item @(row_odd ? "at-column-item-odd" : "")'&gt;@row_odd&lt;/div&gt;
      row_odd = !row_odd;
  }
  </code></pre>
  
  <p>I'm trying to find why the <code>if</code> statment does not work correctly in the string of the css, because if i move to another place work perfectly.</p>
  
  <p>Any idea?</p>