I found a VB version of this here, but I’d like to use a Lambda Expression to take a List of strings and then prepend a string onto every item in the list.
It seems like using the ForEach ends up sending in the string by value, so any changes disappear. Here’s the line of code I was hoping to have work.
listOfStrings.ForEach((listItem) => {listItem = listItem.Insert(0,"a");});
Strings are immutable, they cannot be altered “in place”. Therefore, you’d have to replace each entry in the list which you cannot do with
List<T>.ForEach. At this point you’d be best just making a new list: