Alex Rivera | Logout

How to split text value into array with words in C#?

Asked 2010-09-09T11:55:13.453
9

Is it possible to save value of txtSearche in array splitted into seperate words?

txtSearche = "put returns between paragraphs";

something like this:

 StringBuilder sb = new StringBuilder(txtSearche);

array1 = sb[1]   = put
array2 = sb[2]   = returns
array3 = sb[3]
array4 = sb[4]
array5 = sb[5]

how to do it correct?

Edit
Report

2 Answers

4

You could use String.Split.

answered 2010-09-09T11:58:01.520
2

Below example will split the string into an array with each word as an item...

string[] words = txtSearche.Split(' ');

You can find more details here

answered 2010-09-09T11:58:49.513

Your Answer