Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 424 Bytes

challenge2.md

File metadata and controls

17 lines (15 loc) · 424 Bytes
public static int Solution(string S)
{
    int max = 0;
    var sentences = S.Split(new char[] { '.', '?', '!' });

    foreach (var sentence in sentences)
    {
        //int length = sentence.Split(' ', StringSplitOptions.RemoveEmptyEntries).Length;
        int length = sentence.Split(' ').Where(t => !string.IsNullOrEmpty(t)).Count();
        if (length > max)
            max = length;
    }

    return max;
}