Good Evening All

Am amazed that i cant use the Replace Function , its Probably the long that i had.

i have the Following code

String Username = "Vuyiswa";

            String Password = "secret";

            String strBody = @"<p>Thank you for using !obooking System <br><br> Username:(Username)<br><br>Password:(Password)<br<br>Kind Regards !oBooking</p>";

            strBody  = Regex.Replace(strBody,Username,"(Username)");

            strBody = Regex.Replace(strBody, Password, "(Password)");

            Response.Write(strBody);

i have tried the Normal replace Function, but the Variables are not returned with the Variables values.

Thanks

Don't use Regex, you're doing literal replacements not pattern replacements.

Try:

string Username = "Vuyiswa";
      string Password = "secret";
      string strBody = @"<p>Thank you for using !obooking System <br><br> Username:(Username)<br><br>Password:(Password)<br<br>Kind Regards !oBooking</p>";
      strBody = strBody.Replace("(Username)", Username).Replace("(Password)", Password);

Thank you very much

That worked like a Charm.

Tell me what is the Difference between this

strBody.Replace("(Username)",Username);
   strBody.Replace("(Password)",Password);

and your code that works like charm

strBody = strBody.Replace("(Username)", Username).Replace("(Password)", Password);

Thanks

This question has already been answered. Start a new discussion instead.