Word count in string pls help.????

  • Thread starter Thread starter steve smith
  • Start date Start date
S

steve smith

Hi i just wanted to knw the quickest way, of obtaining a count of the
number of words in a string?

Also how could I then output these words to a file, with only one word
on each line in file, in alphabetical order , the first letter of the
word capitalised and with no duplicates? Any help would be much
appreciated. Thanks
 
steve smith said:
Hi i just wanted to knw the quickest way, of obtaining a count of the
number of words in a string?

Also how could I then output these words to a file, with only one word
on each line in file, in alphabetical order , the first letter of the
word capitalised and with no duplicates? Any help would be much
appreciated. Thanks

1) Split the string into an array of strings using the space character as
the separator
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=28

2) Iterate through the array and add each elements to a new ArrayList unless
the element is already there, using the Contains method

3) Sort the new ArrayList
http://msdn.microsoft.com/library/d...fSystemCollectionsArrayListClassSortTopic.asp

4) Output this "distinct" array into a new file
 
Back
Top