Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual C#
Strings
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:

Want more? Here are some additional resources on this topic:

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Verbatim String Literals      bugout429   |   Edit   |   Show History

An easily overlooked feature of the String in C# is the Verbatim String Literal. By prefixing a string literal with "@", you can insert line breaks and other special characters into a string, and the C# compiler will interpret everything between the open and closing quotation marks as the contents of that string. Note that quotation marks within the string need to be doubled, or else the compiler will assume it has hit the end of the string literal.

Example:

string script = @"<script language='javascript'>
 function SelectedValue(selectBox, valueToSelect)
 {
  if (selectBox.options.length > 0)
  {
   for (var i = 0; i < selectBox.options.length; i++)
   {
    var currentOpt = selectBox.options[i];
    if (currentOpt.value == valueToSelect)
    {
     selectBox.selectedIndex = i;
     alert(""Found a match!"");
     break;
    }
   }
  }
 }
 </script>";

 

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker