Win Surprise Gifts!!!
Top 5 Contributors of the Month
Post New Question
Subscribe to Forum
Count no.of spaces between each word
January 23, 2015
I want to check whether a string contains specified no. of spaces. For eg:- If the input string is AY 12Y 50W 123 1B, I want to count the spaces between each. If space between the words is not 3, an error should be generated. The code am using is shown below:-
int cnt = 0;
for (int k = 0; k < s.Length; k++)
if (s[k] == ' ')
while (Char.IsLetterOrDigit(s[k]) == true);
if (Char.IsLetterOrDigit(s[k]) == true && cnt == 3)
else if (cnt > 3)
With this code I am able to count upto 12Y only. The iteration is not proceeding further as I gave break in between. But if break is not given all the input are treated as error. Can any one suggest a method to resolve the problem.
No response found. Be the first to respond this post
To post reply
Related Questions Related Questions
How to count number of Days present?
Datatable to word
fill existing microsoft word document from sql table
How to count online visitor in asp.net
Pdf to word converting
Search any Word from oracle Bfile
source code for exporting sharepoint list items to word
how to highlight the search word result
Regular expression validator for string and white spaces
Latest Forum Questions From The Same Category
How do i get payment status in redirect page using bitpay?
Login with Facebook and Save details in database
Login with facebook account in my website
How to make a nested datalist control?
What class does Icon derive from?
What are the validation controls?
What''s the difference between an interface and abstract class?
How to read Unicode form PDF File and Save into DataBase ?
How to identify the color format of eps/tiff using c#?
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more
Quick Links For Forum Categories:
Hall of Fame
Terms of Service
Tell A Friend