Hello everyone! I have this assignment that says: Create an application to let the user enter a sentence, then calculate how many words there are in that sentence. I know how to count the "Char" in a word (using .Length), but for this assignment, I really have no idea how to count the words in a sentence. What kind of method am I supposed to use for this particular assignment?
TommyTran
0
Newbie Poster
Recommended Answers
Jump to PostHave you looked into using the String.Split function?
Do Sentance.Split(" ") and it will return an array with the delimiter being the space, which is exactly what you need. Just take the Array.Length-1 and you have your total number of words.
Otherwise, you'll have to loop through each …
All 3 Replies
Stevoni
14
Junior Poster in Training
ChrisPadgham
113
Posting Whiz
Stevoni
14
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.