Pages

Sunday, July 14, 2013

Split a String by Multiple Characters C#



 string words = "This is a list of words, with: a bit of punctuation \tand a tab character.";

        string[ ] splitArray = words.Split(new Char[ ] { ' ', ',', '.', ':', '\t'},StringSplitOptions.RemoveEmptyEntries);

                                             


Here,

"StringSplitOptions.RemoveEmptyEntries"  is used removes the spaces.

We will Get the splitted words in the array "splitArray"

No comments:

Post a Comment