View Single Post
  #5 (permalink)  
Old December 2nd, 2010, 11:58 AM
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
Default

I think I'm not making myself clear. Maybe that's because I'm Dutch?

First of all, in the example with @int, the at sign is not just another character in the variable name. The @int is a verbatim identifier. This means it makes it possible to create a variable named int, even though int is a keyword in C#. Since the @ isn't part of the variable name itself, buff and @buff in your code would refer to the same variable (the same lvalue as well as the same rvalue).

But verbatim identifiers are not what my question's about. My question is why you use the at sign in the @buff and @startingPath.Text on the righthand side of the operator. Like I mentioned before, I see no difference in the process step of the program if I leave out the at sign. If you type a "\" in the textbox, the Text property will show you "\\". If you'd type in a tab character, the Text property would show "\t", but if you type "\t" it would show "\\t".

If you try this
Code:
string startingPath = startingPathTextBox.Text;
string startingPath2 = @startingPathTextBox.Text;
if (startingPath.Equals(startingPath2))
{
  MessageBox.Show("They are the same!");
}
you'll see the strings are the same.

Either with or without the @, the variable startingpath will contain "C:\\Temp" after I've typed in C:\Temp in the textbox. For the @buff I see no difference either. And by not seeing any difference, I mean I've checked the value of startingPath in the debugger.