View Single Post
  #7 (permalink)  
Old December 2nd, 2010, 06:42 PM
comecme comecme is offline
Registered User
Join Date: Nov 2010
Location: Noardburgum, Friesland, The Netherlands
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts

I have no idea why someone might want to use @int as a variable name, I was just showing that the at sign in front of a variable name is used to make that possible. Let's not talk about @int any more.

The use of the at sign in front of a string literal is clear to me. @"C:\Temp" is the same as "C:\\Temp".

But why do you use the at sign in method btnList_Click of listing 13-1 in the book?
startingPath = @txtStartingPath.Text;
and in ShowDriveInfo?
DriveInfo myDrive = new DriveInfo(@buff);
You are the one who started using @ in front of a variable name, not me.
In these lines of code, we are not talking about a verbatim string literal. There are no string literals in this code!

Again, if I remove both @'s in listing 13-1, I get the exact same results. So, is there any reason to use the @ in these two lines of code?

Last edited by comecme; December 2nd, 2010 at 06:51 PM..