如果是用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(7, 4);
}
else
{
result = "游客";
}
return result;
}
{
string result = string.Empty;
if (_phone.Length == 11)
{
result = _phone.Insert(3, "****").Remove(7, 4);
}
else
{
result = "游客";
}
return result;
}
可能还有更好的办法~~我总觉得我的那个方法有点笨~~
麻烦知道的回复一条的~