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

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -