devxlogo

Marking strings with a different color in source code documents

Marking strings with a different color in source code documents

When you build strings by concatenating hardcoded constant strings and variable strings, it’s easy to forget a closing double quote, and thus receive a compile time error when you launch or compile the program (actually, you see that there is a syntax error even before, because the statement gets underlined to signal the error). VS.NET’s syntax highlighting feature can make things much easier, by using a different color to mark the hardcoded strings present in your code.

To specify a color different from the default (also used for normal text/code), open the Options dialog window (Tools | Options…), select the Environment | Fonts and Colors page, select String from the listbox control, and finally select a color for it, red for example. Go back to the source code editor, and note that the strings are rendered in red, making it easier to quickly find them among the rest of the code. When you’re writing code and type a double quote ( ” ), the following code will be immediately rendered in red until you type a closing double quote – this way you’ll never miss a double quote again!

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist