473,395 Members | 1,783 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,395 software developers and data experts.

The @ symbol

hello,

What does the "@" symbol do in the following line of code? I tried
searching the web but searching for "@ and c#" seems to be a waste of
time :)

FileInfo fi = new FileInfo(di.FullName + @"\myxmlfile.xml");

Thanks,
-J

Feb 15 '06 #1
7 1271
>FileInfo fi = new FileInfo(di.FullName + @"\myxmlfile.xml");

It makes it a verbatim string literal where \ isn't treated as an
escape character. It's equivalent to the regular string
"\\myxmlfile.xml".

You may also want to consider calling System.IO.Path.Combine instead
of doing straight string concatenation.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Feb 15 '06 #2
It indicates that the string should be taken as-is: the backslash in
this case is _not_ an escape character. It's meant to make writing
Windows / DOS pathnames easier. Rather than having to write this:

FileInfo fi = new FileInfo(di.FullName + "\\myxmlfile.xml");

so that the \\ resolves into a single \, you can specify no escapes:

FileInfo fi = new FileInfo(di.FullName + @"\myxmlfile.xml");

so here the compiler doesn't attempt to resolve "\m" into a special
character. This can be very handy if you're using UNC names:

string myPath = @"\\unix1\tiffs\product\4x4\M0356A.tif";

instead of (yuck):

string myPath = "\\\\unix1\\tiffs\\product\\4x4\\M0356A.tif";

Feb 15 '06 #3
<kn*********@gmail.com> wrote:
What does the "@" symbol do in the following line of code? I tried
searching the web but searching for "@ and c#" seems to be a waste of
time :)

FileInfo fi = new FileInfo(di.FullName + @"\myxmlfile.xml");


See http://www.pobox.com/~skeet/csharp/s....html#literals

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 15 '06 #4
In addition to what others have said it can also be used on identifiers
to allow language keywords as names. It's not something you see very
often though. For example, a VB.NET developer could decide that the
identifier "sealed" would be a good name for a property not knowing
that it is a keyword in C#. A C# developer using the VB.NET code would
need to qualify it with an @.

Brian

kn*********@gmail.com wrote:
hello,

What does the "@" symbol do in the following line of code? I tried
searching the web but searching for "@ and c#" seems to be a waste of
time :)

FileInfo fi = new FileInfo(di.FullName + @"\myxmlfile.xml");

Thanks,
-J


Feb 15 '06 #5
Thanks for the info :)

Feb 15 '06 #6
Thanks for the info :)

Feb 15 '06 #7
Brian Gideon <br*********@yahoo.com> wrote:
In addition to what others have said it can also be used on identifiers
to allow language keywords as names. It's not something you see very
often though. For example, a VB.NET developer could decide that the
identifier "sealed" would be a good name for a property not knowing
that it is a keyword in C#. A C# developer using the VB.NET code would
need to qualify it with an @.


Of course, anyone following the .NET naming conventions would
automatically avoid all C# keywords because all keywords in C# are in
lower-case, and all non-private members in the .NET naming conventions
are PascalCased :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 15 '06 #8

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

Similar topics

0
by: Richard | last post by:
I am setting up HS in 8i, when I go to $ORACLE_HOME/bin and do a ldd hsodbc i get the below error message, I have done a relink to recreate the hsodbc executable but still no luck. I do have a tar...
0
by: John Graat | last post by:
Hi all, I've built the STLport-462 library on AIX-4.3.3 using gcc-3.3.2. No errors during compilation. However, during linking the following error occurs: ld: 0711-317 ERROR: Undefined symbol:...
9
by: Prasad | last post by:
HI, I am a beginner in VC++.. I am trying to write a Win32 console application in visual studio.. I am using following header files.. #include <STRING> using namespace std; #include...
1
by: vsp15584 | last post by:
Hii..i use the coding as below :- import java.applet.applet; import java.awt.*; import com.sun.j3d.utils.applet.mainframe; import com.sun.j3d.utils.universe.*; import...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
1
by: yamitmehta | last post by:
When I compile to code using g++arm of VxWorks 5.5 and put it on my board i get the follwing undefined symbols:- Cpool and Csingleton are template classes. CPool has the static member...
6
by: sadegh | last post by:
Hi I have a problem with my program in VC++6 When I compile it, the following errors are listed. I spend a lot of time on the groups.google.com to find its reason, but none of comments could...
2
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
0
by: Ryan Gaffuri | last post by:
hlink72@hotmail.com (Eric) wrote in message news:<ab8d8b14.0308220550.54fb5f22@posting.google.com>... LNK1120 is a standard C++ error. you using Visual C++? Means your references a class that...
3
by: Sindhu Rani | last post by:
i hav created 3 classes in 3 different files. am gettin an error durin compilation. wat shud i do??? C:\s\source>javac -d ..\classes devtestdrive.java devtestdrive.java:5: cannot resolve symbol...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.