How to Remove the last char of String in C#?

anon picture anon · Oct 7, 2013 · Viewed 133.2k times · Source

I have a numeric string, which may be "124322" or "1231.232" or "132123.00". I want to remove the last char of my string (whatever it is). So I want if my string is "99234" became "9923".

The length of string is variable. It's not constant so I can not use string.Remove or trim or some like them(I Think).

How do I achieve this?

Answer

amin picture amin · Oct 7, 2013
YourString = YourString.Remove(YourString.Length - 1);