Tom*_*len 1 c# asp.net string replace str-replace
// Build email link
confirmLink = Master.siteDomain + "/newsLetter.aspx?action=confirm&e=" + emailAddress + "&code=" + verCode;
using (SqlCommand cmd = new SqlCommand("SELECT newRegEmailBody, newRegEmailSubj FROM tblSiteSettings WHERE (isActive = 1)", Master.cn))
{
SqlDataReader rdr = cmd.ExecuteReader();
if (rdr.Read())
{
emailBody = rdr[0].ToString();
emailSubj = rdr[1].ToString();
}
rdr.Close();
}
emailBody.Replace("[CONFIRMATION_LINK]", confirmLink);
emailer.sendEmail(emailAddress, Master.noReplyEmail, emailSubj, emailBody);
Run Code Online (Sandbox Code Playgroud)
这一切似乎都很好,除了身体仍然出现[CONFIRMATION_LINK]在文本中,任何想法?
字符串是不可变的.字符串操作通常返回新的字符串实例 试试这个:
emailBody = emailBody.Replace("[CONFIRMATION_LINK]", confirmLink);
Run Code Online (Sandbox Code Playgroud)