Tuesday, 20 August 2013

One line If statement with Razor and .NET

One line If statement with Razor and .NET

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

No comments:

Post a Comment