Razor is a markup syntax that allows you to embed server-based code (Visual Basic and C#) into web pages.

Server-based code creates dynamic web content as the web page is delivered to the browser. When a web page is requested, the server executes the server-based code in the page before returning the page to the browser. Run by the server, the code can perform complex tasks, such as accessing a database.

Razor is based on ASP.NET and is designed for creating web applications. It has the functionality of traditional ASP.NET, but is easier to use and easier to learn

Razor - C# variables syntax

Variables are used to store data.

A variable name must begin with an alphabetic character and cannot contain spaces or reserved characters.

A variable can be of a specified type, indicating the type of data it stores. The string variable stores a string value ("Welcome to RUNOOB.COM"), the integer variable stores a numeric value (103), the date variable stores a date value, and so on.

Razor - C# variables example

// Using the var keyword:
var greeting = "Welcome to php.cn";
var counter = 103;
var today = DateTime.Today;
// Using data types:
string greeting = "Welcome to php.cn";
int counter = 103;
DateTime today = DateTime.Today;