I have a string where the third last character is sometimes a , If this is the case I want to replace it with a . The string could also have other
,
.
string text = "Hello, World,__"; if (text.Length >= 3 && text[text.Length - 3] == ',') { text = text.Substring(0, text.Length - 3) + "." + text.Substring(text.Length - 2); } // text == "Hello, World.__"