Archive

Posts Tagged ‘C#’

Verbatim Characters

March 28, 2010 Leave a comment

A verbatim string is a string that is interpreted by the compiler exactly as it is written, which means that even if the string spans multiple lines or includes escape characters, these are not interpreted by the compiler and they are included with the output. The only exception is the quotation mark character, which must be escaped so that the compiler can recognize where the string ends.

string address = @”C:\Software\Books\Beginning”;

As you can see, verbatim is indicated with an ‘@’ sign at the beginning of a string.

If you want to use a quotation mark inside a verbatim string, you must escape it by using another set of quotation marks.

Example:

string greetings = @”"”Hello everyone”".said the trainer.”;

Categories: ASP.NET, OOP Concept Tags: ,
Follow

Get every new post delivered to your Inbox.