Are there any differences between those examples in terms of performance
First
Difference between this
@foreach (...)
{
@Html.DisplayFor(...)
}
and that
@foreach (...)
{
Html.DisplayFor(...);
}
Second
Difference between this
@{
foreach (...)
{
}
if(...)
{
}
}
and that
@foreach (...)
{
}
@if(...)
{
}
No. In the first two examples, the @ is simply ignored. In the second example, it differs in that you have two code blocks instead of one. This does not measurably influence performance.