一些有用的UtilityExtend小方法
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小方法的更多相关文章
- android 小方法
小方法 1.获取屏幕分辨率: public class BaseTools { public static int getWindowWidth(Context context) { // 获取屏幕分 ...
- jQuery提供的小方法
jQuery提供的小方法: 1.选择器 + 事件 + 函数 = 复杂的交互 2.循环处理与选择器匹配的各个元素:each() $("#").each(function(){ ...
- WinForms C#:html编辑器工程源码,含直接写WebBrowser的文件流、IPersistStreamInit接口的声明和一些相关的小方法
原文:WinForms C#:html编辑器工程源码,含直接写WebBrowser的文件流.IPersistStreamInit接口的声明和一些相关的小方法 首先多谢朋友们的捧场: 今天给大家带来一个 ...
- SharePoint 查找字段内部名称的小方法
今天逛博客园,偶然看到了下面的文章,介绍不用工具查看SharePoint字段内部名称,也介绍下自己的小方法. http://www.cnblogs.com/sunjunlin/archive/2012 ...
- wdatepicker控件de使用小方法汇总
在总结wdatepicker控件的使用前,先插播一条吧,下午刚心血来潮百度的一条 问?C#中Int16.Int32.Int64.之间的区别,:::嘿嘿其实百度知道就有,但还是写上吧! Int16 表示 ...
- 提高django model效率的几个小方法
django的model效率不是很高,特别是在做大量的数据库操作的时候,如果你只用django来开企业站或者外包项目的话,那可以小跳过下,而你恰巧是效率狂或者说是对程序的效率要求比较高的话,那就要注意 ...
- python - 常用的小方法
常用的小方法: bin() oct() hex() chr() ord() dir() id() len() int() str() type() help() range(10) / rang ...
- (转)java中查找List的快捷小方法
相信java开发的程序员,经常会遍历list里的数据,来查找想要的数据.之后选出来在做处理,我这有个小方法在大量数据的情况下能更快捷,当然这方法只对菜鸟有点用,对老鸟来说也许有更好的方法,请指点 遍历 ...
- C#中DEV控件,XtraTabPage得小方法
DEV控件设计窗体程序,XtraTabPage用到的小方法,欢迎大家评论,分享技术! //DEV中的选项卡 private bool TabCtlPageExist(string pageName) ...
随机推荐
- 专访高磊:安卓APK安全加固的引领者
高磊,爱加密CEO,安卓巴士版主之一,曾编写河南省某地市交通信息化规划十二五规划,以及参与省厅级资源共享平台设计等.之前的工作经理积累了丰富的设计规划经验,此外还具有J2EE和 Android开发经验 ...
- [UWP]一种利用Behavior 将StateTrigger集中管理的方案
不做开篇废话,我们发现: AdaptiveTrigger 不够好 我们知道,UWP可以在一个页面适应不同尺寸比例的屏幕.一般来说这个功能是通过官方推荐的AdaptiveTrigger 进行的. 比如这 ...
- mysql保留关键字 BigDecimal Double 四舍五入
`desc` 需要加引号 BigDecimal progress = new BigDecimal(0.444); progress=progress.setScale(2, BigDecimal ...
- Scala 深入浅出实战经典 第40讲:Set、Map、TreeSet、TreeMap操作代码实战
王家林亲授<DT大数据梦工厂>大数据实战视频 Scala 深入浅出实战经典(1-64讲)完整视频.PPT.代码下载:百度云盘:http://pan.baidu.com/s/1c0noOt6 ...
- ios开发中的C语言学习—— 结构体简介
在开发过程中,经常会需要处理一组不同类型的数据,比如学生的个人信息,由姓名.年龄.性别.身高等组成,因为这些数据是由不同数据类型组成的,因此不能用数组表示,对于不同数据类型的一组数据,可以采用结构体来 ...
- 关于css布局的几篇文章
这可能是史上最全的CSS自适应布局总结 (http://www.cnblogs.com/qieguo/p/5421252.html) 使用 CSS 弹性框 (https://developer.moz ...
- vim之插入
进入vim插入模式,我们熟知的有: 字符位置插入: i 在光标之前插入 a 在光标之后追加 行位置插入: A 在一行的结尾处追加 I 在一行的开头处插入 o 在光标所在位置的 ...
- 【css】ie6 和 ie7 下 position 与 overflow 的问题
前几天做的项目中碰到这样一个问题,在 ie6 和 ie7 下,给父元素设置 overflow:hidden 不起作用无法隐藏,后来发现是子元素中有设置 position:relative,如果子元素删 ...
- Kafka - 消费接口分析
1.概述 在 Kafka 中,官方对外提供了两种消费 API,一种是高等级消费 API,另一种是低等级的消费 API.在 <高级消费 API>一文中,介绍了其高级消费的 API 实现.今天 ...
- 深入浅出 nginx lua 为什么高性能
最近很多人问我nginx lua的优势是什么?为什么? 一.同步和异步.阻塞和非阻塞 如果要说清楚这个问题首先要了解:同步和异步.阻塞和非阻塞的关系 同步:php.java的正常代码都是同步执行的 异 ...