public static bool StartBy(this string thisValue, params string[] startBy)
{
foreach (string item in startBy)
{
if (thisValue.StartsWith(item))
return true;
} return false;
} public static bool StartBy(this string thisValue, string startBy, char splitSign)
{
string[] starts = startBy.Split(splitSign);
if (starts.Length > 0)
foreach (string item in starts)
{
if (thisValue.StartsWith(item))
return true;
} return false;
} public static bool IsMatch(this string thisValue, string regexPattern)
{
return Regex.IsMatch(thisValue, regexPattern);
} public static string ReplaceString(this string thisValue, string regexPattern, string replacement)
{
//Bug Fix
if (!string.IsNullOrEmpty(thisValue))
{
return Regex.Replace(thisValue, regexPattern, replacement, RegexOptions.IgnoreCase);
}
return string.Empty;
} public static bool IsIn(this string thisValue, params string[] stringCollect)
{
if (stringCollect == null || stringCollect.Length <= 0)
return false; return Array.IndexOf(stringCollect, thisValue) > -1;
} public static T IfNullThen<T>(this object thisValue, T val)
{
return thisValue == null ? val : (T) thisValue;
} public static string[] GetSubString(this string thisValue, string regexPattern)
{
string[] result = null;
MatchCollection collection = Regex.Matches(thisValue, regexPattern, RegexOptions.IgnoreCase);
if (collection.Count > 0)
{
result = new string[collection.Count];
for (int i = 0; i < collection.Count; i++)
{
result[i] = collection[i].Value;
}
} return result;
} public static string GetHashCode(this string thisValue, int leftLength)
{
string hashCode = Newegg.BigData.Framework.Common.ShareFunctions.GetHashCode(thisValue);
return hashCode.Length >= 4 ? hashCode.Substring(0, leftLength) : hashCode;
} public static string GetRowKeyHashCode(this string thisValue)
{
return thisValue.GetHashCode(4);
}

  

一些有用的UtilityExtend小方法的更多相关文章

  1. android 小方法

    小方法 1.获取屏幕分辨率: public class BaseTools { public static int getWindowWidth(Context context) { // 获取屏幕分 ...

  2. jQuery提供的小方法

    jQuery提供的小方法: 1.选择器 + 事件 + 函数 = 复杂的交互 2.循环处理与选择器匹配的各个元素:each() $("#").each(function(){     ...

  3. WinForms C#:html编辑器工程源码,含直接写WebBrowser的文件流、IPersistStreamInit接口的声明和一些相关的小方法

    原文:WinForms C#:html编辑器工程源码,含直接写WebBrowser的文件流.IPersistStreamInit接口的声明和一些相关的小方法 首先多谢朋友们的捧场: 今天给大家带来一个 ...

  4. SharePoint 查找字段内部名称的小方法

    今天逛博客园,偶然看到了下面的文章,介绍不用工具查看SharePoint字段内部名称,也介绍下自己的小方法. http://www.cnblogs.com/sunjunlin/archive/2012 ...

  5. wdatepicker控件de使用小方法汇总

    在总结wdatepicker控件的使用前,先插播一条吧,下午刚心血来潮百度的一条 问?C#中Int16.Int32.Int64.之间的区别,:::嘿嘿其实百度知道就有,但还是写上吧! Int16 表示 ...

  6. 提高django model效率的几个小方法

    django的model效率不是很高,特别是在做大量的数据库操作的时候,如果你只用django来开企业站或者外包项目的话,那可以小跳过下,而你恰巧是效率狂或者说是对程序的效率要求比较高的话,那就要注意 ...

  7. python - 常用的小方法

    常用的小方法: bin() oct() hex() chr() ord() dir() id() len() int() str() type() help() range(10)   /  rang ...

  8. (转)java中查找List的快捷小方法

    相信java开发的程序员,经常会遍历list里的数据,来查找想要的数据.之后选出来在做处理,我这有个小方法在大量数据的情况下能更快捷,当然这方法只对菜鸟有点用,对老鸟来说也许有更好的方法,请指点 遍历 ...

  9. C#中DEV控件,XtraTabPage得小方法

    DEV控件设计窗体程序,XtraTabPage用到的小方法,欢迎大家评论,分享技术! //DEV中的选项卡 private bool TabCtlPageExist(string pageName) ...

随机推荐

  1. Docker实践(1)—入门

    tutorial centos6.5环境. # yum install docker-io -y 会依赖安装libcgroup,lxc,lxc-libs 启动docker # service dock ...

  2. 【转】javascript运行机制之this详解

    this是面向对象语言中一个重要的关键字,理解并掌握该关键字的使用对于我们代码的健壮性及优美性至关重要.而javascript的this又有区别于Java.C#等纯面向对象的语言,这使得this更加扑 ...

  3. runtime MethodSwizzle 实践之 奇怪crash : [UIKeyboardLayoutStar release]: message sent to deallocated instance

    情景: 使用MethodSwizzle 实现对数组.字典 等系统方法的安全校验.显然能达到预期效果,但实际发现当 键盘显示的情况下  home app 进入后台,再单击app  图标 切换回前台时 发 ...

  4. 新安装的VS的一些设置

    古语云:工欲善其事必先利其器 为了方便我们开发,应该设置好VS的一些配置,安装一些辅助插件 1 设置字体和背景等 设置字体为 console 10大小 背景设为护眼颜色 85 90 205 这三个值 ...

  5. 对于程序开发者看书(指实在的书而不是PDF)的好处。(个人看法而已)

    书是实在的东西.不同PDF.他能带你进入一种学习态度的环境 书上已经所列了知识点.看了.那些知识点就是你的. 第一次看,未必完全理解到里面的东西.说不定过几天,几周,几个月,甚至几年.再看.就有可能看 ...

  6. log4j总结

    log4j介绍 Log4j是Apache的一个开放源代码项目,通过使用Log4j,我们可以控制日志信息输送的目的地是控制台.文件.GUI组件.甚至是套接口服务 器.NT的事件记录器.UNIX Sysl ...

  7. define 与 inline

    define 就是代码替换,在编译阶段进行简单的代码替换,大量用于宏定义开关,以及定义表达式和常量,如: 1.开关定义 #define CONFIG_OPENED 使用: #ifdef CONGFIG ...

  8. android studio出现Error:compileSdkVersion android-x requires compiling with JDK 7问题

    初装Android studio的童鞋可能或多或少会存在一些问题,比如出现Error:compileSdkVersion android-x requires compiling with JDK 7 ...

  9. dnspod动态域名使用感受

    继花生壳不能用之后,3322也开始不太好用了,首先就是360把所有3322的域名全部判定为危险域名,甚至拦截程序对于3322url的api请求. 所以想把3322换成我们自己的独立域名,但是3322他 ...

  10. Oracle 11g RAC客户端使用SCAN IP无法连接问题

    Oracle 版本:11.2.0.1.0 客户端:Windows Server 2003/PLSQL Developer Oracle服务器端的ip设置如下: ##公网ip 192.168.135.2 ...