Reputation: 6242
I have a list as:
var myList = lookuplist;
//where lookupList
Count = 2
[0]: "36"
[1]: ""
Above list is basically being populated by parsing from my excel file. Sorry the code before this is not relevant so not showing that.
My issue is I want to update the empty string with a space. So I tried the code below:
myList .Where(w => w.Length == 0).Select(y=>y = " ").ToList();
But it does not changes anything.
Am I missing something here. I can use a forach to loop through my list but I want to use linq.
Sorry if this is trivial.
Upvotes: 1
Views: 1738
Reputation: 4336
You have to assign the updated list back to the original variable. You can do something like this:
myList = myList.Select(y => string.IsNullOrEmpty(y) ? " " : y).ToList();
Upvotes: 5