There are a little error in your statements.
If you try your program with the string:  "this  is a test" (2 spaces between this and 
is) word count is 5 instead the correct
result (4)

-------------------------------------------
Bastianello Luciano 
Software Consultant - Apprentice Sorcerer
Tel: 335 8300440 - Fax: 049 58631182
e-mail: [EMAIL PROTECTED] 
e-mail: [EMAIL PROTECTED]
ICQ: 209754422 - MSN: [EMAIL PROTECTED]
------------------------------------------- 


-----Messaggio originale-----
Da: G.Waleed Kavalec [mailto:[EMAIL PROTECTED] 
Inviato: domenica 26 settembre 2004 22.07
A: [EMAIL PROTECTED]
Oggetto: Re: [Microsofts_C_Sharp] word_counter

I use the   .Split(' ')  approach

string in = "this is a test";
string [] out;

out = in.Split(' ')  ;

Now just get the upperbound of out plus 1.  

This is only better than regex if you are going to manipulate the
words, and you are also advised to sqeeze out extra spaces.


----- Original Message -----
From: shaheener <[EMAIL PROTECTED]>
Date: Thu, 23 Sep 2004 23:50:19 -0000
Subject: [Microsofts_C_Sharp] word_counter
To: [EMAIL PROTECTED]

i wanna make a c# program that counts the no. of words in a 
sentence. i used the ".Length" method but this only counts the no. 
of charcters. So please if anyone got the idea to count words i'd 
appreciate it if he posted it.



Yahoo! Groups Sponsor

ADVERTISEMENT


________________________________
Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/Microsofts_C_Sharp/
  
To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
  
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 



-- 
 
G. Waleed Kavalec
-------------------------------------
Inna-lillahi-wa inna ilayhi-raji'oon



 
Yahoo! Groups Links



 




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/XGgtlB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/Microsofts_C_Sharp/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to