@{ var total = 7; } @{ var greeting = "Welcome!"; var weekDay = DateTime.Now.DayOfWeek; var leapYear = DateTime.IsLeapYear(DateTime.Now.Year); var greetingMessage = greeting + " Today is: " + weekDay + " -Leap year: " + leapYear;
The greeting is :
@greetingMessage
The value of your account is: @total
} @* End of greeting *@Last week: @DateTime.Now - TimeSpan.FromDays(7)
@*Add () to get correct time.*@Last week: @(DateTime.Now - TimeSpan.FromDays(7))
@*End of correct time*@ Support@contoso.comThe path is: @myFilePath
@myQuote
@{ var inCSharp = true;Now in HTML, was in C# @inCSharp
} @{ /* C# */Hello World
/* This is not C#, it's HTML */ }Hello World
/* This is not C#, it's HTML */The value was even
} else if (value >= 1337) {The value is large.
} else {The value was not large and is odd.
}The value is 1!
break; case 1337:Your number is 1337!
break; default:Your number was not 1 or 1337.
break; } @* *@ @try { throw new InvalidOperationException("You did something invalid."); } catch (Exception ex) {The exception message: @ex.Message
} finally { // Do something. }The greeting is :
Welcome! Today is: Tuesday -Leap year: True
The value of your account is: 7
The value of myMessage is: Hello World