We can remove last character in many ways.
What do you think on this topic? Please express your opinion through comment below
- Using substring function
- Using Remove Function
Using Substring function
String city = "pune;"
newCity = city.Substring(0, city.Length - 1);
Using Remove function
String city = "pune;"
newCity = city.Remove(city.Length - 1);
We can also remove the last character from the string using a loop. Loop will run from 0 to string's length -1.