I have the following code:
@foreach (UserAccount ua in company.Users) { @ua.userName, }
To print:
user1, user2, user3,
How to get rid of the last ","?
Using String.Join :
String.Join
@(string.Join(company.Users.Select(u => u.UserName), ", "))
use String.Join . it will handle the last comma for you.
@(string.Join(company.Users.Select(x => x.userName), ", "))
Source: https://habr.com/ru/post/1479745/More articles:SQL Basic Concurrency - sqlJava imposes final software - javaHow to avoid screen flicker? - c #Marker color change in Google Maps V2 - javais there any way to check if the debugger is currently attached? - visual-studioEmail HTML document embedding images using C # - htmlI am weird behavior - ruby-on-railsExtension methods and type inference - c #How to get the point of interest near my point using overpass-api? - openstreetmapcreate a grid without spaces using the html table - htmlAll Articles