本示例将一串字符串以空格键分割成数组元素。
using System; namespace a { class Program { public static void Main(string[] args) { string myString ="This is a test."; char[] separator={' '}; string[] myWords; myWords=myString.Split(separator); foreach (string word in myWords) { Console.WriteLine("{0}",word); } Console.ReadKey(); } } }