c# 统计文本单词shu

有一段文本,“Because of you I never stray to far
from the sidewalk Because of you I learned to play
on the safe side ” 要求:
1.将文本中的所有you 换成 lanou, to 换成 too。
2.统计出此段文本中有多少个单词;

string arr = " Because of you I never stray to far from the sidewalk Because of you I learned to play on the safe side ";
string s = arr.Replace ("you", "lanou");
string s1 = s.Replace ("to", "too");
Console.WriteLine (s1);

    string[] temp = s.Split (new char[]{ ' ' }, StringSplitOptions.RemoveEmptyEntries);
    Console.WriteLine (temp.Length);
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。