Search code examples
c#stringtrim

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


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?


Solution

  • YourString = YourString.Remove(YourString.Length - 1);