Hi Everyone!
I was wondering if someone could help me. I have some long strings that have words that are delimited by a semi-colon and I want to divide the words and put them into a list if possible. For example, I have a string like this: ships in 2 boxes; great value; on sale; this item includes free shipping; buy one get one free
I want to manipulate this string to something like:
- ships in 2 boxes
- on sale
- this item includes free shipping
- buy one get one free
or something similar. Could someone please give me a tip and point me in the right direction?
Thanks in advance
Jay
AlanPosted Sep 3, 2008, 2:29 PM
You can use the String.Split() method for this:
string text = "ships in 2 boxes; great value; on sale; this item includes free shipping; buy one get one free";
string[] items = text.Split(new string[]{"; "}, StringSplitOptions.None);
foreach(string item in items)
{
Console.WriteLine(item);
}
To convert the array to a list:
List list = new List(items);
JayPosted Sep 3, 2008, 2:47 PM