C#如何取出一行中的字符数包括空格,单词?

解决方案 »

  1.   

    string a = "fsfr frf,gtjgt g  geghieben";
    char[] b = a.ToCharArray();
      

  2.   

    字符数??
                string a = "fsfr frf,gtjgt g  geghieben";
                int num = a.Length;
      

  3.   

    http://www.360doc.com/content/10/0511/05/19147_27005282.shtml正则表达式例子
      

  4.   

    string yourStr = "测试字符串 test 123";
    yourStr.Length;//字符数
    System.Text.RegularExpressions.Regex.Matches(yourStr,@"\w+(-\r?\n\w+)?").Count;//单词数
      

  5.   

    string yourStr = "测试字符串 test 123";
    yourStr.Length;//字符数
    System.Text.RegularExpressions.Regex.Matches(yourStr,@"\w+(-\r?\n\w+)?").Count;//单词数
    System.Text.RegularExpressions.Regex.Matches有Count的方法吗?
    没有吧
      

  6.   

    我用的vs2010,是有的,2008也有,难道2005没有?2005打了sp1补丁的也有。
      

  7.   

    n=System.Text.Encoding.Default.GetByte(str).Length    '//单个字符序列
      

  8.   

    n=System.Text.Encoding.Default.GetBytes(str).Length '//单个字符序列
      

  9.   

    学习了!!!这才是真正的免费美国空间
    申请地址:http://www.qiongzz.com/freeweb(ftp-calvin)我正在使用的空间