Remove the Last Character in a String via CSharp
I was compiling a string this afternoon with several options drawn from the database. I put in a hyphen to seperate each element to keep everything looking neat. It was something like this:
That is all nice and good and all, but it gives us one too many trailing hyphens like this:
Lettuce – Tomato – Onion -So to get around this, we need to chop off that last character from the string so we have a clean string. The solution is very simple. We call the Remove() function and point it to one character before the end of our string (determined by calculating the length of the string). Consider that sucker removed.
