Casey Crookston Casey Crookston - 8 days ago 6
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:


Item1

Item2

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

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

Comments