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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

String 2
String to Enumeration 1
Check if String is Empty 2
Regular Expression 1
Separate String 3
String 1
String size 1
Enumeration - How to do this? 1

Back
Top