What's the @ operator do?

  • Thread starter Thread starter stork
  • Start date Start date
S

stork

If I see a piece of code like:

someobject.stringProperty = @mycontrol.Text;

What does the @ do in that case?

Is that a clone operator?
 
If I see a piece of code like:

someobject.stringProperty = @mycontrol.Text;

What does the @ do in that case?

Is that a clone operator?

the @ can be used with strings. not sure if can be used with var
names.
For strings you can use for @"c:\Docs\Source\a.txt" rather than "c:\
\Docs\\Source\\a.txt"

Al Schulz
http://alsql.blogspot.com
 
If I see a piece of code like:

someobject.stringProperty = @mycontrol.Text;

What does the @ do in that case?

Is that a clone operator?

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.
From MSDN
http://msdn.microsoft.com/en-us/library/aa664670(VS.71).aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top