当前位置:首页 > ASP.net(c#)字符串替换简单例子

ASP.net(c#)字符串替换简单例子

点击次数:815  更新日期:2010-12-28
\n

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String str = “<>>”;
String b = cleanStr(str);
this.Label1.Text=b;


\n


}
public string cleanStr(String str)
{
StringBuilder bs = new StringBuilder(str);
bs = bs.Replace(“<”,”&lt;”);
bs = bs.Replace(“>”, “&gt;”);
return bs.ToString();
}


}

\n