挖土

Coding for fun.
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

给string加几个扩展方法

Posted on 2010-03-31 14:58  挖土.  阅读(438)  评论(3编辑  收藏  举报

 

代码
    public static class StringExtend
    {
        
public static bool IsNullOrEmpty(this string s)
        {
            
return string.IsNullOrEmpty(s);
        }

        
public static bool IsInt(this string s)
        {
            
int i;
            
return int.TryParse(s, out i);
        }

        
public static int ToInt(this string s)
        {
            
return int.Parse(s);
        }
    }