C# ASP.NET for loop issue -
in code behind have list of names...(tracy, michelle , tiffany)
and have string called names , each name gets added string, displays (tracy michelle tiffany)
how after each name gives comma , before last one, put and..
here of code
string names = ""; for(int i=0; i< groupofpeople.count; i++) { groupofpeople nm = (groupofpeople) nm.groupofpeople[i]; names += nm.firstname; }
do like
for(int i=0; i< groupofpeople.count; i++) { groupofpeople nm = (groupofpeople) nm.groupofpeople[i]; if(i < groupofpeople.count - 1) names += nm.firstname + ", "; else names += " , " + nm.firstname; }
Comments
Post a Comment