public static void Main()
Console.WriteLine("Enter sentence for conversion");
string input =Console.ReadLine();
string output = Paragraph.ToSentenceCase(input);
Console.WriteLine(output);
public abstract class Paragraph
public static string ToSentenceCase(string text)
while (temporary.Length>0)
string[] splitTemporary = splitAtFirstSentence(temporary);
temporary = splitTemporary[1];
if (splitTemporary[0].Length>0)
result += capitaliseSentence(splitTemporary[0]);
result += capitaliseSentence(splitTemporary[1]);
private static string capitaliseSentence(string sentence)
sentence = sentence.Remove(0,1);
result += sentence.TrimStart().Substring(0, 1).ToUpper();
result += sentence.TrimStart().Substring(1, sentence.TrimStart().Length-1);
private static string[] splitAtFirstSentence(string text)
int lastChar = text.IndexOfAny(new char[] {'.', ':', '\n', '\r', '!', '?'})+1;
return new string[] { text.Substring(0, lastChar), text.Substring(lastChar, text.Length-lastChar) };