I know we use @ symbol to switch between C# code and html code, but for code like this below:
@for (int i = 1; i <= 10; i++)
{
@i
}
why can we still place @ before i as @i? Since there is no html element here,so there is no switching and i is the c# code, if we just use "i" instead of "@i", we should get the same output?
Another question is :
@for (int i = 1; i <= 10; i++)
{
<b>@i</b>
if (i % 2 == 0)
{
<text> - Even </text>
}
else
{
<text> - Odd </text>
}
<br />
}
why we don't need to place @ before if since < /b> before if indicates that it is current in html mode, and then we need to do like
@if (i% 2 == 0)
{
...
}