Split String Into Array by Delimiter

Posted: December 14, 2011 in ASP.Net

To split a string by a delimiter into an array, you can try the following:

string myContact = "1|2|3|4|5";
string[] myContactArray = myContact.Split('|');
foreach (string myContactValue in myContactArray)
{
  Console.WriteLine(myContactValue);
}    
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s