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. 向Spotify学习如何设计产品(转)

    导语:Spotify是瑞典的精益创业项目,同时保持着很棒的产品交付记录.一般在产品上线之后,开发者才知道人们喜不喜欢它.Spotify如何解决这个问题? 本文转自 kent.zhu's Blog,原文 ...

  2. Flask-Babel 中文支持(zh-CN和zh-Hans-CN)

    命名的翻译文件夹必须命名为zh_Hans-CN,其他的都是不标准的命名!

  3. 使用nginx-http-concat优化网站响应

    前言: 我们在访问淘宝的时候,会看到代码中的js和css文件是通过一次请求或得的,我们知道浏览器一次请求只能并发访问数个资源,这样的处理错输在网络传输层面可以大大节省时间,这里使用的技术就是把css. ...

  4. js获取gridview模板列中textbox行列的值

    下面一个例子:在gridview中第一列输入数值,第二列输入数值,点击第三列的时候进行计算 求和,如果不符合标记为红色字体. 如图: 代码 : <html xmlns="http:// ...

  5. 软件包管理 之 RPM 基础 《RPM 的介绍和应用》

    RPM 是 Red Hat Package Manager 的缩写,本意是Red Hat 软件包管理,顾名思义是Red Hat 贡献出来的软件包管理:在Fedora .Redhat.Mandriva. ...

  6. CSS选择器实现搜索功能 驱动过滤搜索技术

    一.CSS选择器可以用来实现搜索功能 CSS选择器可以用来实现搜索功能. 作者以前提过CSS3的选择器结合表单元素可以用来控制元素的显隐,这里,类似的,还是CSS3的选择器,用来过滤和搜索页面元素. ...

  7. 【Cocos2d-Js基础教学(4)cocostudio在cocos2dx-Js中的使用】

    首先我们打开官方网站www.cocos2d-x.org,下载我们安装最新的cocostudio(cocos). 简介: Cocos Studio升级为cocos.更优秀的产品.更优质的服务.游戏开发一 ...

  8. Raft论文的一些问题

    抛些问题出来,真正解释了这些问题才算理解了论文.:) 1. 什么是复制状态机 2. Raft vs Paxos 3. Raft的设计目标understandability,为达到设计目标在做设计时如何 ...

  9. WinStore开发知识导航集锦

    1.页面导航与页面传值:http://blog.csdn.net/tcjiaan/article/details/7895487

  10. Ubuntu 16.04 LTS更新

    Canonical今天正式发布了新版的Ubuntu系统,针对PC.笔记本.上网本.平板和智能手机各类设备.这次的Ubuntu 16.04代号为Xenial Xerus——这个代号是由Canonical ...