We help IT Professionals succeed at work.
Get Started

Replacing line breaks in string with VB/C#.NET new line

Last Modified: 2012-05-09
We have a series of confirmation email text stored in the web.config of various web applications.  Some web applications use VB.NET, some use C#.  The text is stored as a basic string data such as

<add key="cfgRegistrationEmailConfirmation" value="Thanks for registering with us.
If you have not registered to use this service, please reply to this email."

If this string is used as-is, the email text comes through like so:

Thanks for registering with us. If you have not registered to use this service, please reply to this email.

The new lines are lost.  I need to replace the text new line character with the Environment.NewLine() but am unsure how to do so.  I have tried replace "\n" but this does not do anything.

What technique should I use to maintain the formatting of these strings as stored in the configuration file for both VB.NET & C#?  Thanks in advance for any help or advice you can offer.
Watch Question
Director, Information Systems
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE