c# - ASP.NET MVC Enumerable to delimited HTML in Razor -


this question has answer here:

i discovered can use string.join(", ", string[] enumerable) turn list of strings single comma delimited string. similar produce example list of hyperlinks in razor view? instead of like:

@foreach(var item in enumerable)  {     <a href="@item.url">@item.title</a>     if(item != enumerable.last()) { <span>, </span> } } 

and if so, advisable or should stop being lazy?

@html.raw(string.join("<span>, </span>", enumerable.select(item => string.format("<a href=\"{0}\">{1}</a>", item.url, item.title)))) 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -