C# 判断整个字符串是否都是中文

时间:2014-09-16 23:34:51   收藏:0   阅读:456
        /// <summary>
        /// 判断字符串全部是否是中文。返回true 则表示含有非中文
        /// </summary>
        /// <param name="str_chinese"></param>
        /// <returns></returns>
        public bool IsChinese(string str_chinese)
        {
            bool b = false;
            for (int i = 0; i < str_chinese.Length; i++)
            {
                Regex reg = new Regex(@"[\u4e00-\u9fa5]");
                if (!reg.IsMatch(str_chinese[i].ToString()))
                {

                    b = true;
                    break;
                }
            }

            return b;

        }

  

原文:http://www.cnblogs.com/albertwmm/p/3976036.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!