I have a list of items which I want to output in a razor view. Between each item I want to add a separator line, like this:
item1 | item2 | item3
Keep a counter variable and inside the loop and check whether it is the last item or not.
@{ int counter=0; }
@foreach(var item in Model.items){
counter++;
@item.Name
if(counter
and the short version is
@{ int counter=0; }
@foreach(var item in Model.items){
counter++;
@item.Name @(counter< Model.items.Count?"|":"")
}