.NET Tip of The Day
Learn one new .NET trick every day
Login or Join
Why does new tips appear on this site so infrequently?

Hi guys. I know some of you are not satisfied with the frequency new tips appear on this site. The last comment I received was a proposal to rename the site to .NET Tip of The Month :) But I don't want to do this because I'm going to fix this problem. I'm working on the .NET Tips & Tricks Community section now. My tips that are too small to hit the front page were added to this section. It's the place where all of you can share your .NET tips and tricks.

It's clear that this section lacks for some features. And if anyone out of 2510 subscribers has a proposal, just drop me a line. My email is kostya.ly@gmail.com.

Thanks for you patience.
Kostya Ly

Verbatim string literals

Verbatim string literal does not require the use of escape characters to define special characters. Instead, any information in the source code, including new lines, is included in the string. To define a string literal an @ symbol is placed before the opening quotation mark. Verbatim string literals are often used for specifying paths and multi-line strings:

    string path = @"C:\Program Files\My Program";        //verbatim literal

    string path2 = "C:\\Program Files\\My Program";      //regular literal

 

    string msg = @"Hello,

            This is a multi-line string";                //verbatim literal

 

    string msg2 = "Hello,\nThis is multi-line string";   //regular literal

P.S. the only character that requires a different action is the quotation mark itself, which must be entered twice to indicate a single character.

10/17/2007
RSS .NET Tip of The Day
Subscribe to receive one tip from the .NET Tips and Tricks Community per day.
Previous Tips of The Day
The best of the .NET Tips & Tricks Community.
.NET Practitioners .NET Tips & Tricks Community
Every .NET practitioner has a trick up in their sleeve. This is the place to share it with other .NET people.
Submit a Tip
Discovered a new trick? Share it with others.
My Tips
Manage tips you authored.