本帖最后由 邢凯 于 2014-8-4 10:58 编辑
- string str = "How are you ? Fine,Thank you !";
- char[] achar = { ' ', '?', '!', ',' };
- string[] words = str.Split(achar, StringSplitOptions.RemoveEmptyEntries);
- Console.WriteLine("上面一共有{0}个单词", words.Length);
- Console.WriteLine("每个单词分别为 ");
- for (int i = 0; i < str.Length; i++)
- {
- Console.WriteLine(words[i]);
- }
- Console.ReadLine();
复制代码
这个程序能读出每个单词,但是运行之后会报错,报错在下面的图片里,希望大伙帮忙看看呗 |
|