Replace String

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
 
H

Hans Kesting

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
 
K

Keith Patrick

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)
 
S

shapper

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top