Not exactly. The substring method will only return N characters. What you
could do instead is find the Nth space. Once you find the Nth space you know
where the Nth word is. Another way would simply to break the string itself
into a string array by breaking the string on a space, which would be the
normal break between words. For example string[] words = myString.Split('
',N);
N is the maximum number of substrings to return, hence the maximum
number of words. You could then iterate the array to concatenate them back
into a string.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
shapper said:
Hello,
I have a string which holds a text.
Is it possible to create a substring which uses the first N words of
that string?
Thanks,
Miguel