I am trying to do a search/replace on values within a List(of String).
Dim l As New List(Of String) From {"Hello", Chr(10), "World"}
Iterate the list, and perform the search and replace:
For Each s As String In l
s = s.Replace(Chr(10), String.Empty)
Next
However, tracing this back out, the Chr(10)
has not been replaced. Chr(10)
is a line break. Tracing with:
Trace.Warn(String.Join(",", l))
outputs
Hello,
,World
Attempting this slightly differently works perfectly however:
For i As Integer = 0 To l.Count - 1
l(i) = l(i).Replace(Chr(10), String.Empty)
Next
Output:
Hello,,World
I thought that s
within the For
loop provided an instance to the actual string, not a copy of it? Can anyone clarify what's going on here?