Razor engine that is used with MVC is identified by the symbol @.
Razor engine is used in MVC for generating views and defining the HTML part.
Single statement block and inline expression
@{ var message = "Hello,Razor view engine";}
Message is : @message
Multi Statement Block
@{
var priciple = 100;
var rate = 12;
var time = 2;
var interest = (priciple * rate * time) / 100;
}
//Interest of @priciple rupees is @interest for @time years
Conditional Statement
@{
var isValid = true;
if(isValid)
{
It is an if statement in code block
}
else
{
It is an else statement in code block
}
}
@if(true)
{
It is a single if block
}
Looping
@{
for(var count = 1;count,=3;count++)
{
@Count is : @count
}
string [] nameArray = {"Sandeep","Mandeep","Kuldeep","Pradeep"};
foreach(var name in nameArray)
{
Your Name is : @name
}
}
0 Comment(s)