3 uses of the @ Symbol in c#

1. You can use one of the reserved words of c# with the @ symbol

Eg :

string @int = "senthil kumar";

or something like this

string @class ="MCA";

Although you can use this , avoid using one.

2. Before a string specially when using the file paths .

You can use

string filepath = @"D:\SENTHIL-DATA\myprofile.txt";

instead of

string filepath = "D:\\SENTHIL-DATA\\myprofile.txt";

3. For a Multi lined text

string ThreeIdiots = @"Senthil Kumar,
Norton Stanley,
and Pavan Rao!";


instead of

string ThreeIdiots = @"Senthil Kumar,\n   Norton Stanley,and Pavan Rao!";

This is what the c# Language specification states about the @ Symbol

“The prefix “@” enables the use of keywords as identifiers, which is useful when interfacing with other programming languages. The character @ is not actually part of the identifier, so the identifier might be seen in other languages as a normal identifier, without the prefix. An identifier with an @ prefix is called a verbatim identifier. Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style.”

Interesting symbol isn’t it ??

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.


  1. Joe Enos January 25, 2011 Reply
  2. Chad Moran January 26, 2011 Reply
  3. Robert January 26, 2011 Reply
    • Senthil Kumar January 26, 2011 Reply
      • Bill Door January 26, 2011 Reply
  4. 3 uses of the @ Symbol in c# | ProgramInDotnet August 8, 2011 Reply

Leave a Reply


Interesting BlogPosts to read

Barracuda Introduces Email Threat Scan for Microsoft Office 365
With the number of advanced threats on the rise and affecting companies of all sizes, Barracuda toda...
How to get an Enumerator from range of elements from ArrayList in C# ?
The code snippet shown in this blog post demonstrates how you can get the enumeraor from a range of ...
How to check for the column name in an SqlDataReader Object in C# ?
When working in ADO.NET for data access , there are times when you want to check to see if a column ...