String and variables

  • Thread starter Thread starter Arjen
  • Start date Start date
A

Arjen

Hi,

For an message with variable values I'm using a string.

Like this:
string message = "Hi " + name + ",\n\n Here is your new password: " +
password;

Is there a way to do it like this:
string message = "Hi v1,\n\n Here is your new password: v2", name, password;

Hope that sombody knows what I want.

Thanks!
 
Use string.Format
In ur case it will be,
string message = String.Format("Hi {0},\n\n Here is your new password: {1}",
name, password);
 
Maqsood Ahmed said:
another thing, I prefer writing Environment.NewLine instead of \n.

That entirely depends on the situation. If you're communicating using a
protocol which specifies which line termination to use, you should use
that directly.

Environment.NewLine is fine for the default line terminator for the
current system, but that doesn't mean it's right for everything.
 
What's the best for a text-based e-mail message?
(Using Environment.NewLine or \n)


Thanks!
 
Arjen said:
What's the best for a text-based e-mail message?
(Using Environment.NewLine or \n)

Well, what are you submitting the email to? I would suggest using \r\n
for email, as that's what RFC 822 uses for line termination - not
Environment.NewLine, as that's not guaranteed to be \r\n on all
platforms.
 
Okay, thanks!

Arjen


Jon Skeet said:
Well, what are you submitting the email to? I would suggest using \r\n
for email, as that's what RFC 822 uses for line termination - not
Environment.NewLine, as that's not guaranteed to be \r\n on all
platforms.
 
Back
Top