Select Sifiso

How to Trim Characters in C#

The removing of leading and trailing characters in c# is made possible by the System namespace.
My demo is uses a windows form to illustrate trimming of characters.
My form looks as shown below.
ctrim1
The default value in my text box is my name printed with leading and trailing characters as ”             Sifiso Ndlovu   “.
When you click the Trim button, you supposed to execute the below code behind the button:
[snippet id=”244″]
The bottom text box is then used to present a trimmed output as shown below:
ctrim2
You can download the solution file here.
Conclusion
That’s all, folks. Till next time.
Cheers,
Sifiso.

Leave a Comment

Your email address will not be published.