fork(3) download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. string str = "12.34.56.78";
  10. Char replaceChar = '.';
  11. int lastIndex = str.LastIndexOf(replaceChar);
  12. if (lastIndex != -1)
  13. {
  14. IEnumerable<Char> chars = str
  15. .Where((c, i) => c != replaceChar || i == lastIndex);
  16. str = new string(chars.ToArray());
  17. }
  18. Console.Write(str);
  19. }
  20. }
Success #stdin #stdout 0.03s 33752KB
stdin
Standard input is empty
stdout
123456.78