user2405975
user2405975

Reputation: 3

Formatting plain text in C#

I am trying to format text that will be sent in an email to a user. Currently, I am simply printing to the console to make sure the formatting is correct. I used all the escape characters I found while doing my research such as /r/n and /t but it's not working. The escape characters just show up in the text. For example, if I were to put

string someStringVar = boo;
"Hello World! /r/n" + someStringVar + "/t Goodbye!", I would expect the text to look like:

Hello World!

boo -tab- Goodbye!

instead, it looks like this:

Hello World! /r/nboo/t Goodbye!

Why???? I'm sure it's some stupid mistake, but I am too frustrated to figure it out. Help!

Upvotes: 0

Views: 1354

Answers (3)

Karl Gjertsen
Karl Gjertsen

Reputation: 4928

If you are testing emails, you might also want to look at Papercut and nDumbster, both of these are available on www.codeplex.com

Upvotes: 0

Haris Hasan
Haris Hasan

Reputation: 30117

instead of /t try \t you are using wrong slash

Same thing is wrong with rest of the escape sequences

Upvotes: 0

SLaks
SLaks

Reputation: 888047

You need to use backslashes:

"Hello World! \r\n" + someStringVar + "\t Goodbye!"

Upvotes: 5

Related Questions