Hi,
I added a string property for my winforms control.
This string property can take multiple lines of text by using "\r\n".
For example, "Hello\r\nWorld"
SHOULD prints:
Hello
World
The problem is that c# _always_ treats my string as _path_ (using @-quoted).
It prints:
Hello\r\nWorld
I would like to get rid of this silly ''@'' in this case.
How do I correct this?
Thanks.
Minh
解决方案C# does not treat strings as "literals" unless they are constants, prefixed with the ''@'' character.
If your property is of type String, then your code must assume that the value passed in to the set accessor is already formatted
correctly. In other words, your code cannot determine whether the caller used the ''@'' symbol.
Do not set your property using the ''@'' character if you want to preserve the "\r\n" escape characters.
--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"Newcomer" wrote in message news:21**************************@posting.google.c om...Hi,
I added a string property for my winforms control.
This string property can take multiple lines of text by using "\r\n".
For example, "Hello\r\nWorld"
SHOULD prints:
Hello
World
The problem is that c# _always_ treats my string as _path_ (using @-quoted).
It prints:
Hello\r\nWorld
I would like to get rid of this silly ''@'' in this case.
How do I correct this?
Thanks.
Minh
The problem is that c# _always_ treats my string as _path_ (using @-quoted).
It prints:
Hello\r\nWorld
Where do you print it? If you view the string in the debugger it may
appear that way.
Mattias
--
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Dave, thanks for your reply.
I DON''T use ''@'' in the string property.
I think, this problem only happends when I tried to set the string value
at _design_time_. C# will detects "\r\n" and treats that as path.
You can test this by having a simple form with a text editor (textBox1).
At design time, set the text value (textBox1) to "Hello\r\nWorld"
(ignore the quotes). Then in your test code, try
Console.WriteLine(textBox1.Text).
You _will_ get just a single line of print out.
That is my problem.
Thanks again.
Ming
*** Sent via Developersdex http://www.developersdex.com ***