开发者

Why doesn't the '\n' performs a new line in this situation?

开发者 https://www.devze.com 2023-02-25 05:32 出处:网络
I\'m getting some text from a database, so I want to view them in a TextBox object. The text in the DB has \\n character开发者_运维知识库 to represent a new line, but when I bind the text to the TextB

I'm getting some text from a database, so I want to view them in a TextBox object. The text in the DB has \n character开发者_运维知识库 to represent a new line, but when I bind the text to the TextBox, the \n still appear without being transformed to new lines!

I've tried the "\r\n" instead with no results!

What's wrong!


If you look at the string in the debugger, I'm willing to bet that it has an \\n in it, not an \n. \\n will be displayed as \n, but \n will be displayed as a newline

string s = "Hello\\nWorld";  // Displays 'Hello\nWorld'

s = "Hello\nWorld";          // Displays 'Hello
                             //           World'
0

精彩评论

暂无评论...
验证码 换一张
取 消