| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Security.Cryptography;
 
- using System.Text;
 
- using System.Text.RegularExpressions;
 
- using System.Threading.Tasks;
 
- namespace Common
 
- {
 
-     public static class StringExtension
 
-     {
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         public static bool IsEmpty(this string str)
 
-         {
 
-             if (string.IsNullOrEmpty(str))
 
-                 return true;
 
-             return false;
 
-         }
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         public static string FormatMe(this string str, params object[] args)
 
-         {
 
-             return string.Format(str, args);
 
-         }
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         public static int TryToInt32(this string str)
 
-         {
 
-             return Int32.Parse(str);
 
-         }
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         public static DateTime ToDateTime(this string str)
 
-         {
 
-             return DateTime.Parse(str);
 
-         }
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         public static string GetMD5(this string str, string salt)
 
-         {
 
-             MD5 md5 = new MD5CryptoServiceProvider();
 
-             byte[] fromData = System.Text.Encoding.Unicode.GetBytes(str + salt);
 
-             byte[] targetData = md5.ComputeHash(fromData);
 
-             string byte2String = null;
 
-             for (int i = 0; i < targetData.Length; i++)
 
-             {
 
-                 byte2String += targetData[i].ToString("x");
 
-             }
 
-             return byte2String;
 
-         }
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         public static int StrToInt(this string str)
 
-         {
 
-             return StrToInt(str, 0);
 
-         }
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         public static int StrToInt(this string str, int defValue)
 
-         {
 
-             if (string.IsNullOrEmpty(str) || str.Trim().Length >= 11 || !Regex.IsMatch(str.Trim(), @"^([-]|[0-9])[0-9]*(\.\w*)?$"))
 
-                 return defValue;
 
-             int rv;
 
-             if (Int32.TryParse(str, out rv))
 
-                 return rv;
 
-             return Convert.ToInt32(StrToFloat(str, defValue));
 
-         }
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         public static float StrToFloat(this string strValue, float defValue)
 
-         {
 
-             if ((strValue == null) || (strValue.Length > 10))
 
-                 return defValue;
 
-             float intValue = defValue;
 
-             if (strValue != null)
 
-             {
 
-                 bool IsFloat = Regex.IsMatch(strValue, @"^([-]|[0-9])[0-9]*(\.\w*)?$");
 
-                 if (IsFloat)
 
-                     float.TryParse(strValue, out intValue);
 
-             }
 
-             return intValue;
 
-         }
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         public static string RemoveValue(this string value, string zf= "zx95")
 
-         {
 
-             return value.Replace(zf, "");
 
-         }
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         
 
-         public static bool IsEnum<T>(this string value)
 
-            where T : struct
 
-         {
 
-             T a;
 
-             if (Enum.TryParse<T>(value, out a))
 
-             {
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-     }
 
- }
 
 
  |