简体   繁体   中英

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!

你需要用

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

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

Same thing is wrong with rest of the escape sequences

如果您正在测试电子邮件,则可能还需要查看Papercut和nDumbster,它们都可以在www.codeplex.com上找到。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM