473,405 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

What's the @ operator do?

If I see a piece of code like:

someobject.stringProperty = @mycontrol.Text;

What does the @ do in that case?

Is that a clone operator?

Jun 27 '08 #1
3 1257
On Thu, 15 May 2008 09:16:30 -0700, stork <tb******@storkyak.comwrote:
If I see a piece of code like:

someobject.stringProperty = @mycontrol.Text;

What does the @ do in that case?

Is that a clone operator?
It's hard to say whether that's even valid code. But assuming it is, it's
indicating to the compiler that the variable "@mycontrol" should not be
confused with some built-in keyword "mycontrol".

Usually you'd only see that in some sort of auto-generated code.
Hand-written code would normally only use "@" if the variable name did in
fact conflict with an existing C# keyword.

Pete
Jun 27 '08 #2
On May 15, 12:16*pm, stork <tband...@storkyak.comwrote:
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
Jun 27 '08 #3
On May 16, 2:16 am, stork <tband...@storkyak.comwrote:
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/libr...70(VS.71).aspx
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Steven Bethard | last post by:
I thought it might be useful to put the recent lambda threads into perspective a bit. I was wondering what lambda gets used for in "real" code, so I grepped my Python Lib directory. Here are some...
70
by: Roy Yao | last post by:
Does it mean "(sizeof(int))* (p)" or "sizeof( (int)(*p) )" ? According to my analysis, operator sizeof, (type) and * have the same precedence, and they combine from right to left. Then this...
9
by: John Cho | last post by:
// CHO, JOHN #include<iostream> class fracpri{ int whole; int numer; int denom;
3
by: John Cho | last post by:
/* This program is a database program that will store video tape names, minutes, year released, and price I want it to be professional so that *YOU* will want to buy it and use it for a video...
8
by: dru | last post by:
Every time I think I know or understand C++ with some confidence, I see something that changes that. I was looking at the boost shared_ptr docs and code, and I ran across the operator...
10
by: Steven T. Hatton | last post by:
I read Stroustrup's article of the day: http://www.research.att.com/~bs/C++.html Programming with Exceptions. InformIt.com. April 2001. http://www.research.att.com/~bs/eh_brief.pdf Some of...
17
by: Anoob | last post by:
Can we consider () unary operator when calling a function, in exps eq. f(), ( 1 + 2). But when we call function f( 10 ) it is a binary operator. Even if we pass f( 10, 20) as we are using ,...
2
by: stella_pigeon | last post by:
Can someone offer me a hint how to correctly program the problem outlined below? I have a template class defines as follows class A { int a1; int a2; operator == ... }
16
by: Ajay | last post by:
Hi all, i want to know when i create a class.what all it contains.I know the following things are there by default if i do not declare them by myself.Please tell the other things that are left. ...
2
by: Peng Yu | last post by:
Hi, In the following code, the 'copy' member function works. But the '=' operator does not work. Can somebody let me know why a member function is different from an operator. Thanks, Peng ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.