I am retrieving a lot of informations in a list, linked to a database.
I want to create a string of groups, for someone who is connected to the website.
I use this to test ... But this is not dynamic so it is really bad:
string strgroupids = "6";
I want to use this now. But the string returned is something like 1,2,3,4,5,
groupIds.ForEach((g) =>
{
strgroupids = strgroupids + g.ToString() + ",";
strgroupids.TrimEnd(',');
});
strgroupids.TrimEnd(new char[] { ',' });
I want to delete the ,
after the 5
but it's definitely not working..
Can someone help me?
Add an extension method.
then use:
As an alternate to adding a comma for each item you could just using String.Join:
This will add the seperator ("," in this instance) between each element in the array.
What about doing it this way
A lot cleaner.
It will append all elements inside
groupIds
with a','
between each, but it will not put a','
at the end.