c# 如何调用 方法? 想实现功能是 有个方法,功能为 [email protected] 返回 abc@***.*** 不知该方法该如何写,并且,放置在哪里才能所有页面都方便调用??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用正则来替换 写一个静态方法,比如StringHelper.HiddenEmail(String email){} 用正则写一个替换邮箱名的方法放app_code中 能写一个么,刚接触不久,写了几种格式总说有错误。放于 App_code 目录下了,不用实现功能也行,我就看看格式 public static string test(string s) { string result; Regex r = new Regex(@"(?<=@).*(?=\.)|(?<=\.).*"); string r1 = r.Match(s).Value; string r2 = r.Match(s).NextMatch().Value; result =s.Replace(r1,new string('*',r1.Length)).Replace(r2,new string('*',r2.Length)); return result; }//将此方法封装在一公共类中 可实现所有页面都能调用//调用时 公共类.test("[email protected]"); 自定义类库,静态方法调的DLL如IPRegex.Replace("", @"((\d{1,3}\.){3,})(\d{1,3})", "$1"+"***"); public static string HiddenEmail(string email) { return email; }这种格式可以吧? 写一个webservice或者写一个静态方法 winfrom事件改写 好奇怪的问题啊?怎么调试的好好的,生成出来功能就不一样了呢 请教一个SQL dataset模糊搜索 如何把“...[...]...”替换成“.../[.../]...”c#中 .net伪静态实现方法 高分求助:如何在水晶报表(.net自带的)中使用自定义纸张? 我在datagrid上面单击后,如何得到我点击的行在所对应的datatable上的行 如何用程序找到打印机 C# 求助:关于中文字符表的排序算法 怎么将这种数据写个循环。。。。。。。。。。。 哪里有最新版的MSDN下载?
写一个静态方法,比如StringHelper.HiddenEmail(String email){}
用正则写一个替换邮箱名的方法放app_code中
public static string test(string s)
{
string result;
Regex r = new Regex(@"(?<=@).*(?=\.)|(?<=\.).*");
string r1 = r.Match(s).Value;
string r2 = r.Match(s).NextMatch().Value; result =s.Replace(r1,new string('*',r1.Length)).Replace(r2,new string('*',r2.Length));
return result;
}
//将此方法封装在一公共类中 可实现所有页面都能调用
//调用时 公共类.test("[email protected]");
调的DLL
如IP
Regex.Replace("", @"((\d{1,3}\.){3,})(\d{1,3})", "$1"+"***");
{
return email;
}
这种格式可以吧?
或者写一个静态方法