3

I have this string :

 string lat ="24.6669863852163";

how can I replace the last Character '3' by '2' ?

2
  • @TimSchmelter - I just realized my mistake (which is why I deleted the comment as it was inaccurate and misleading). Commented Jul 3, 2013 at 8:42
  • question is not clear. Replacing only "3" by "2", or any character by precedent ? lat.Substring(0, lat.Length - 1) + (char)(lat[lat.Length - 1] - 1) Commented Jul 3, 2013 at 8:45

2 Answers 2

15
lat = lat.Substring(0, lat.Length-1) + "2";
Sign up to request clarification or add additional context in comments.

1 Comment

No offense, but why was there no explanation?
4
lat = lat.Remove(lat.Length - 1) + "2";

1 Comment

Substring would be a better choice than Remove

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.