using System; using System.Linq; using System.Collections.Generic; public class Test { public static void Main() { string str = "12.34.56.78"; Char replaceChar = '.'; int lastIndex = str.LastIndexOf(replaceChar); if (lastIndex != -1) { IEnumerable chars = str .Where((c, i) => c != replaceChar || i == lastIndex); str = new string(chars.ToArray()); } Console.Write(str); } }