What is the @ at symbol for?

  • Thread starter Thread starter needin4mation
  • Start date Start date
N

needin4mation

In this code:

XmlTextWriter myWriter = new XmlTextWriter(@"C:\Xmldata\myWriter.xml",
null);


Why do they have the @ at symbol? Why not just the string?
 
You can also use it in front of any variable name to allow keywords to
be used as variables. This is legal C#:

public bool DontDoThis()
{
bool @true = false;
return @true == true;
}

Brian
 
The @ symbol specifies that the string will be used literally so that you
can type @"c:\foo\bar" instead of "c:\\foo\\bar". Be aware however that
double quotes are needed if you wish to include quote marks in your string.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Back
Top