The easiest way to split a string

Here's the code for splitting a string in C#.

Please let other users know how useful this tip is by rating it at the bottom of this page. Do you have a tip or code of your own you'd like to share? Submit it here.


using System;
using System.Windows.Forms;
class MainClass
{
 public static void Main(string[] args)
 {
 string MainString = "String Manipulation"; 
 string [] Split = MainString.Split(new Char [] {' '}); 
 //SHOW RESULT 
 MessageBox.Show(Convert.ToString(Split[0])); 
 MessageBox.Show(Convert.ToString(Split[1])); 
 }
}

This was last published in February 2004

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close