c# - In Razor, how do I print a loop with delimiter? -
i have following code:
@foreach (useraccount ua in company.users) { @ua.username, }
which print:
user1, user2, user3,
how rid of last ","?
using string.join
:
@(string.join(company.users.select(u => u.username), ", "))
Comments
Post a Comment