Is there an easy way to remove the first 2 and last 2 chars in a string?
I have this string:
\nTESTSTRING\n
How could I easily delete them?
str = str.Substring(2,str.Length-4)
Of course you must test that the string contains more than 4 chars before doing this. Also in your case it seems that \n is a single newline character. If all you want to do is remove leading and trailing whitespaces, you should use
str.Trim()
as suggested by Charles
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With