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 Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/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