Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Smooth Sentences c#

public static bool IsSmooth(string sentence)
{
    sentence = sentence.Trim().ToLower();
    string[] sentences = sentence.Split(' ');

    if (sentence.Length <= 1) return false;

    for (int i = 0; i < sentences.Length - 1; i++)
    {
        string previousWord = sentences[i];
        char lastChar = Char.Parse(previousWord.Substring(previousWord.Length - 1));

        string followingWord = sentences[i + 1];
        char firstChar = Char.Parse(followingWord.Substring(0, 1));

        if (lastChar != firstChar) return false;
    }

    return true;
}
Source by blog.armanimichael.com #
 
PREVIOUS NEXT
Tagged: #Smooth #Sentences
ADD COMMENT
Topic
Name
2+8 =