Replace String

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I have a string as follows: myString = "This is a <username> for you"

I want to replace <username> by "mig".

How can I do this?

Thanks,

Miguel
 
Hello,
I have a string as follows: myString = "This is a <username> for you"

I want to replace <username> by "mig".

How can I do this?

Thanks,

Miguel

myString = myString.Replace("<username>", "mig");


Hans Kesting
 
If this is so you can provide a custom string every time, the more standard
approach is to define a string resource:
"This is a {0} for you"

And then use:
String.Format(CultureInfo.CurrentCulture, "This is a {0} for you", "mig");
(the culture stuff isn't required, but FxCop will flag that if you don't)
 
I didn't completely understood what you explain but basically I am
sending an email to a user which asked to reset its password so I want
to replace in a standard text the user name and the new generated
password.

Thanks,
Miguel
 
Back
Top