c# - Removing a node from a list using a for -


here have done:

// example of function, string , remover should variables string delimeter = ","; string remover="4"; string[] separator = new string[] { "," }; list<string> list = "1,2,3,4,5,6".split(separator, stringsplitoptions.none).tolist(); (int = 0; < list.count - 1; i++) {     if(list[i]==remover)         list.removeat(i); } string allstrings = (list.aggregate((i, j) => + delimeter + j)); return allstrings; 

the problem retruned string same originial one, same "1,2,3,4,5,6". "4" still in it.

how fix it?

edit:

the solution didnt check last node of list in for, doesnt seem in example because example gave now

when remove items list should make loop run in reverse, highest index lowest.

if go lowest highest end shifting items down removed , skip items. running in reverse not have issue.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -