using System.Collections.Generic;
public static void Main()
var sentence ="my name is john. i am 23 years old.";
string[] words = sentence.Split(' ');
var result = words.Select(x => x.EndsWith('.') ? $".{x.Trim('.')}" : x);
Console.WriteLine(string.Join(" ", result));