C# 字符串 包含中文

  /// <summary>
        /// 判断字符串 是否含有中文
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        private bool ContainCHChar(string str)
        {
            int chnfrom = Convert.ToInt32("4e00", 16);
            int chnend = Convert.ToInt32("9fff",16);
            bool result = false;
            for (int i = 0; i <= str.Length - 1; i++)
            {
                char temp = str[i];
                int charNum = Convert.ToInt32(temp);
                if (charNum >= chnfrom && charNum <= chnend)
                {
                    result = true;
                    break;
                }
            }
            return result;
        }

 

posted on 2012-06-25 21:20  imihiro  阅读(745)  评论(0编辑  收藏  举报