c# – How do I remove a substring in a string?

Question:

For example, how can you remove the \n in the line?

string str= "\n   14.56.67   \n"

Answer:

The bottom line is that all the methods presented do not change the original string.
Thus, to get the result, you need to assign it either to the same variable or to another, for example:

var replaced = str.Trim();
Scroll to Top