Show array contents

circle-info

You can use dotnet watch and observe the result of code changes instantly on the browser!

Show array items one by one

Wrong

@page

@{
    string[] names = { "Raj", "Sam", "Ted", "Kim" };
}

@foreach(var name in names){
    <p>name</p>
}

Right

@page

@{
    string[] names = { "Raj", "Sam", "Ted", "Kim" };
}

@foreach(var name in names){
    <p>@name</p>
}

Even better

Output

circle-info

What did you notice in this line?

<p>Name @(i+1): @name</p>

Last updated