title: One line If statement with Razor and .NET
body: <p>Razor doesn't seem to like my one line <code>If</code> statements... Normally in VB.NET, I can write a one line <code>If</code> statement like so:</p>
  
  <pre><code>If True Then Dim x As Integer
  </code></pre>
  
  <p>However, when I do the same with Razor in a <code>.vbhtml</code> file like this...</p>
  
  <pre><code>@If True Then Dim x As Integer
  </code></pre>
  
  <p>I get the error</p>
  
  <blockquote>
    <p><em>The "If" block was not terminated. All "If" statements must be terminated with a matching "End If"</em>.</p>
  </blockquote>
  
  <p>What gives? Why won't Razor take this? I realize that a simple solution is to just use a code block like</p>
  
  <pre><code>@code
      If True Then Dim x As Integer
  End Code
  </code></pre>
  
  <p>But thats not what I'm looking for. I'm curious why Razor can't recognize a VB.Net one line <code>If</code> statement using just <code>@If...</code>. Any ideas?</p>