您当前的位置: 首页 >  c#

C#字符串的使用

发布时间:2010-11-22 10:36:00 ,浏览量:0

一、标记 标记(tokenizing)是从文本中提取具体内容的过程。 下面的代码从句子中提取单词,并把它们输出到控制台。 class mytokenizing {    static void Main(string[ ] args)    {       string mystring="I like this food,are you?";       char[] separators={' ',',','?',':','!'};       int startpos=0;       int endpos=0;       do       {          endpos=mystring.IndexOfAny(separators,startpos);          if ( endpos==-1 ) endpos=mystring.Length;          if ( endpos!=startpos )               Console.WriteLine(mystring.Substring( startpos,(endpos-startpos)));          startpos=(endpos+1);       }while(startpos

关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    108476博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0533s