Answers for "words count in c#"

C#
1

words counter c#

int count = inputstring.Split(' ').Length;
Posted by: Guest on July-17-2021
0

words counter c#

int wordCount = 0, index = 0;

// skip whitespace until first word
while (index < text.Length && char.IsWhiteSpace(text[index]))
    index++;

while (index < text.Length)
{
    // check if current char is part of a word
    while (index < text.Length && !char.IsWhiteSpace(text[index]))
        index++;

    wordCount++;

    // skip whitespace until next word
    while (index < text.Length && char.IsWhiteSpace(text[index]))
        index++;
}
Posted by: Guest on March-24-2022

C# Answers by Framework

Browse Popular Code Answers by Language