首页  :: 新随笔  :: 订阅 订阅  :: 管理

手机号码搞成中间4位用*隐藏起来的那种形式~

Posted on 2008-03-10 14:17  礼拜一  阅读(4087)  评论(2编辑  收藏  举报

如果是用sql直接搞~~可以这样搞~~

select isnull(stuff(user_phone,4,4,'****'),'游客'as user_phone from tbl_user


如果在程序里边搞~~那就这么搞~~

public string StuffPhone(string _phone)
    
{
        
string result = string.Empty;
        
if (_phone.Length == 11)
        
{
            result 
= _phone.Insert(3"****").Remove(74);
        }

        
else
        
{
            result 
= "游客";
        }

        
return result;
    }


可能还有更好的办法~~我总觉得我的那个方法有点笨~~
麻烦知道的回复一条的~