C# 如何取得汉字的字符长度

public  int calStrLen(string Str)

{

  int i=0;

  if(Str==null)

  {

     return i;

  }

  else

  {

    foreach(char c in Str)

    {

      if(c>0x4e00&&c<=0x9fa5)

        {

        i++;

        }

        i++;

    }

  return i;

  }

 

  

}

posted @ 2014-11-12 20:24  jiang_jiang  阅读(282)  评论(0编辑  收藏  举报