You cannot use string.Replace this way (using a global string); you have to use a string.Replace for each character to replace.
Example:
l = l.Replace("-", "").Replace(":", "").Replace("_", "").Replace("|", "");
Notes:
- string.Replace does not proceed to an in-place editing of the variable, you have to cast the result of the method to the variable again (
l = ...
).
- You can chain the calls to the Replace method.
- In the code block you showed, in the commented line, you seem to use a
line
which does not match the
l
variable defined in your foreach loop.
There are other options to do the same, using regular expressions for example, but I think some directions already have been given to you on this subject in some other posts.
Hope this helps. Kindly.