I show the categories of my i'th product on the View, but I want to add a link and put commas between them.
@for (int i = 0; i < Products.Count(); i++)
{
<tr>
<td>
<span> @Model.Products[i].ProductName </span>
@foreach (var item in Model.Products[i].ProductCategories)
{
<a href="/home/@item.ItemName"> @item.ItemName, </a>
}
</td>
</tr>
It looks like this => Computer, Technology, Desktop,
I want this => Computer, Technology, Desktop
I don't want a comma in the last itemI can show it this way but I can't add <a href=""></a>
<span>@string.Join(", ", Model.Products[i].ProductCategories.Select(p => p.Category.CategoryName))</span>