Quitar espacios al final de un String en C#

Es posible que nos encontremos con un String que, normalmente por error, contiene espacios al final. Para eliminarlos nos basta con implementar la función “TrimEnd”.

string myText = "one;two;three;four;five           ";
myText = myText.TrimEnd(' ');
//El resultado será: "one;two;three;four;five"

Categories:

C#

No Responses

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.