xxx.txt 文件有(Love is like collecting shells)
读取 xxx.txt 文件 统计文件里的有多少个单词,请问高手怎么做
------解决方案--------------------------------------------------------
用空格分割放到一个数组里
数组的长度就是单词的个数
------解决方案--------------------------------------------------------
- C# code
string path = "c:\\test.txt"; StreamReader sr = new StreamReader (path); string [] s = sr.ReadLine().Split(' '); s.Length//这就是单词个数