Casey Crookston Casey Crookston - 1 year ago 105
ASP.NET (C#) Question

Remove item from list<> inside string.join

String.Join("<br>", ProductList)

ProductList is a List. So, this returns a tidy little:



Item3 etc

What I need to do is just remove the first item.

String.Join("<br>", ProductList.RemoveAt(0))

That doesn't work, because RemoveAt returns void. I'm sure this is simple... I'll probably smack myself in the forehead when I see the answer.

Answer Source

It is really simple using the IEnumerable.Skip extension

String.Join("<br>", ProductList.Skip(1))

However this doesn't remove anything, just the first item in the list is skipped and not passed to the Join method

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download