Thursday, August 13, 2009

 

Use Shift+Enter to insert '\n' characters using the Visual Studio resource editor

This is by no means something new. It's just something I always forget to do, and forget how to do, so I figured I would post it here so I know where to find it when I need it again.

I often use hard-coded strings for message boxes, UI strings, etc. when I initially write the code, and then go back later to add all of those hard-coded strings into resource files so that they can get localized. When adding such strings to resource files, one cannot simply cut and paste it from the source code to the resource file because of the embedded control characters.

The C# Compiler knows that when it sees "\n" in a string [ that does not start with '@' ] it should replace that two-character substring with the '\n' control character. However, the resource files are not so smart; the substring "\n" in a resource string is not converted to the '\n' control character automatically. But, you can insert a '\n' newline control character into the resource string by using Shift+Enter in the Visual Studio resource editor. (For some reason, I always want to do a Ctrl+Enter but that does not work).

Comments:
Hi dear,
Actually i want to replace a string in word file while find and replace. But i am doing that from C#. Can you please tell me how to insert new line in word while find and replace from c#.

I know it is Shift+enter but what char i should use in c# string for this combination.
Please help me out
 
Thanks mate, simple and useful!
 
Post a Comment





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]