I have the following code:
@foreach (UserAccount ua in company.Users) {
@ua.userName,
}
Which would print:
user1, user2, user3,
How do I get rid of the last ","?
Using String.Join
:
@(string.Join(company.Users.Select(u => u.UserName), ", "))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With