@{ 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.com

@("Hello World")

@Html.Raw("Hello World")

@{ var myFilePath = @"C:\MyFolder\"; }

The path is: @myFilePath



@{ var myQuote = @"The person said: ""Hello, today is Monday."""; }

@myQuote

@{ var inCSharp = true;

Now in HTML, was in C# @inCSharp

} @{ /* C# */I'm HTML /* C# */ }

@{ /* Still C# */@:

Hello World

/* This is not C#, it's HTML */ }

@{ /* Still C# */

Hello World

/* This is not C#, it's HTML */
} @{ var @value = 77; } @if (value % 2 == 0) {

The value was even

} else if (value >= 1337) {

The value is large.

} else {

The value was not large and is odd.

}

@switch (value) { case 1:

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. }

@{ /* C# comment. */ // Another C# comment. } @* @{ /* C# comment. */ // Another C# comment. } *@

The greeting is :
Welcome! Today is: Tuesday -Leap year: True

The value of your account is: 7

The value of myMessage is: Hello World