因为要用javascript输出一段字符串,为了不出错应该过滤掉这个字符串中会引起错误的危险字符,希望哪位能帮忙用C#写个函数!谢谢了~
private string ReplaceStr(string str)
{
string ReplaceStr = str;
ReplaceStr.Replace("'","").Replace("\"","");
return ReplaceStr;
}
參考答案:c#
private string ReplaceStr(string str)
{
string retStr=str.Replace("'","").Replace("\"","");
return retStr;
}
或者
public string replace(string str)
{
StringBuilder s=new StringBuilder(str);
s.Replace("'","\"");
s.Replace("\"","");
//..你还可以再写
return s.ToString();
}