Problem registry value is read as verbatim

  • Thread starter Thread starter Fred
  • Start date Start date
F

Fred

Hello,

Is there a way to read values from the registry as regular instead of
verbatim?

Regards,
Fred
 
Mattias Sjögren said:
What do you mean by regular and verbatim in this context?

Hi Mattias,

When I read a string value from the registry then the string is formatted
with @ in the begin. I want to read it regular so that I can use the \r and
etc in the string for text formatting.

Regards,
Fred
 
Jon Skeet said:
You're being confused by the debugger.

Hi Jon,

Compiled as release same "problem", when I add a \r or whatever to the
string in the register and write it to a textbox for testing the \r is
displayed as \r instead of a return. Is there another solution for this?

Regards,
Fred
 
Fred said:
Compiled as release same "problem", when I add a \r or whatever to the
string in the register and write it to a textbox for testing the \r is
displayed as \r instead of a return. Is there another solution for this?

If it's \r in the textbox itself, then that's in the registry. You can
replace all occurrences of "\r" with CR, but you need to know for
certain what you really expect in the registry.
 
Jon Skeet said:
If it's \r in the textbox itself, then that's in the registry. You can
replace all occurrences of "\r" with CR, but you need to know for
certain what you really expect in the registry.

Hi Jon

What I want is that a string stored in the registry something like this
'Thank you \r\n second line' read out of the registry and use that in a
e-mail. When I remove the @ in debug mode or create the string in the
program then it works. Only when a read the string from the registry it is
not formatted like the way I want.

Regards,
Fred
 
The problem is that when you put "Thank you \r\n second line" in C#
source code the compiler replaces the \r and \n with appropriate
characters in the compiled code. That does not happen at run-time.
To gain this behavior at you'll need to do a replace on the string to
replace the escape characters you want to support with their actual
values.

Best regards,

Sam


Hi Jon

What I want is that a string stored in the registry something like this
'Thank you \r\n second line' read out of the registry and use that in a
e-mail. When I remove the @ in debug mode or create the string in the
program then it works. Only when a read the string from the registry it is
not formatted like the way I want.

Regards,
Fred

B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
 
Fred said:
What I want is that a string stored in the registry something like this
'Thank you \r\n second line' read out of the registry and use that in a
e-mail. When I remove the @ in debug mode or create the string in the
program then it works. Only when a read the string from the registry it is
not formatted like the way I want.

I suggest you read the whole of the page I linked to before, and
understand what the @ is actually doing when it's in source code, and
what the difference is between a string literal in source code and the
string itself.
 
Back
Top