字符串操作
2012-04-24 22:34 精诚所至 金石为开 阅读(171) 评论(0) 编辑 收藏 举报本示例将一串字符串以空格键分割成数组元素。
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(); } } }
![](https://img2024.cnblogs.com/blog/35695/202502/35695-20250207193659673-708765730.jpg)