View Single Post
  #6 (permalink)  
Old December 2nd, 2010, 04:37 PM
DrPurdum DrPurdum is offline
Friend of Wrox
Points: 1,166, Level: 13
Points: 1,166, Level: 13 Points: 1,166, Level: 13 Points: 1,166, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Sep 2008
Location: Indianapolis, IN, USA.
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts
Default @ Operator

We're probably talking at cross purposes.

First, I was just wondering why you would use the statement

int @int = 1;

What did you have in mind? I can't imagine a good reason for such code.

Second, the @ operator is really used for string literals, or quoted strings, in the code. Look at the following statements in the debugger and it may become clear what the operator does:

string startPath1 = @"C:\\temp";
string startPath2 = "C:\\temp"; ;

The result is that startPath1 ends up looking like "C:\\\\temp" while startPath2 has "C:\\temp". In the first case, the literals causes the compiler to view the backslashes as escape sequences, so it translates the literal. The @ operator simply saves the programmer some typing when path names are hard coded. Without the @ operator, what you see is what you get.
Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)