c# 常用基本函数

1、去除字符串中的所有空格

///


        /// 去除字符串中的所有空格
        ///

        ///
        ///
        internal static string TrimAllSpace(this string str)
        {
            return Regex.Replace(str, @"\s+", string.Empty);
        }

2、检查字符串是否全由数字组成

 ///


        /// 检查字符串是否全由数字组成
        ///

        ///
        ///
        internal static bool IsNumeric(this string str)
        {
            long num;
            return long.TryParse(str, out num);
        }
 

3、检查字符串数组中是否包含某字符串

///


        /// 检查字符串数组中是否包含某字符串(不区分大小写)
        ///

        ///
        ///
        ///
        internal static bool Contains(this string[] strArray, string str)
        {
            bool result = false;
            foreach (string item in strArray)
            {
                if (string.Equals(str, item, StringComparison.OrdinalIgnoreCase))
                {
                    result = true;
                    break;
                }
            }

            return result;
        }

你可能感兴趣的:(c#,java,服务器)