as

Sunday, 19 January 2014

How to remove last character from the string in C#.Net

We can remove last character in many ways.
  1. Using substring function
  2. 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. 

What do you think on this topic? Please express your opinion through comment below

Sponsored Links

Popular Posts

Comments

ShareThis