473,406 Members | 2,336 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,406 software developers and data experts.

what does @ symbol means in c#

thi
Hi,

Just curious what does the @ system means in c#. Some of the sample codes i
read it written as:

bool bExists = File.Exists(@"c:\\hello.txt");

but i can get the same result as using

bool bExists = File.Exists("c:\hello.txt");

Does @ has special meaning?

Thanks
Jul 19 '06 #1
5 4163
"thi" <th******@hotmail.comwrote in message
news:OD**************@TK2MSFTNGP03.phx.gbl...
Hi,

Just curious what does the @ system means in c#. Some of the sample codes
i read it written as:

bool bExists = File.Exists(@"c:\\hello.txt");

but i can get the same result as using

bool bExists = File.Exists("c:\hello.txt");

Does @ has special meaning?
Look more closely at those two statements and you'll see the difference.
Then, get a book on C#.

///ark
Jul 19 '06 #2
Hello Mark,

The @ is used to to not require escape sequences. For example:

@"C:\Hello";

is C:\Hello

But:
"C:\Hello";

isn't valid because the \H is an escape sequence.

But...

"C:\\Hello"

is equivalent to:

@"C:\Hello"

Because \\ is an escape sequence for \

Does this help at all? Still using the @"" format is still not the same
as using VB.NET strings (as you can still continue a string past the end
of a line). FOr example:

string s = @"SELECT *
FROM Customers";

Is perfectly valid in C#, but in VB.NET this does not work:

dim s as String = "SELECT *
FROM Customers"

Thanks,
Shawn Wildermuth
Speaker, Author and C# MVP
http://adoguy.com
"thi" <th******@hotmail.comwrote in message
news:OD**************@TK2MSFTNGP03.phx.gbl...
>Hi,

Just curious what does the @ system means in c#. Some of the sample
codes i read it written as:

bool bExists = File.Exists(@"c:\\hello.txt");

but i can get the same result as using

bool bExists = File.Exists("c:\hello.txt");

Does @ has special meaning?
Look more closely at those two statements and you'll see the
difference. Then, get a book on C#.

///ark

Jul 19 '06 #3
Hello Mark,

The @ is used to to not require escape sequences. For example:

@"C:\Hello";

is C:\Hello

But:
"C:\Hello";

isn't valid because the \H is an escape sequence.

But...

"C:\\Hello"

is equivalent to:

@"C:\Hello"

Because \\ is an escape sequence for \

Does this help at all? Still using the @"" format is still not the same
as using VB.NET strings (as you can still continue a string past the end
of a line). FOr example:

string s = @"SELECT *
FROM Customers";

Is perfectly valid in C#, but in VB.NET this does not work:

dim s as String = "SELECT *
FROM Customers"

Thanks,
Shawn Wildermuth
Speaker, Author and C# MVP
http://adoguy.com
"thi" <th******@hotmail.comwrote in message
news:OD**************@TK2MSFTNGP03.phx.gbl...
>Hi,

Just curious what does the @ system means in c#. Some of the sample
codes i read it written as:

bool bExists = File.Exists(@"c:\\hello.txt");

but i can get the same result as using

bool bExists = File.Exists("c:\hello.txt");

Does @ has special meaning?
Look more closely at those two statements and you'll see the
difference. Then, get a book on C#.

///ark

Jul 19 '06 #4
"thi" <th******@hotmail.comwrote in message
news:OD**************@TK2MSFTNGP03.phx.gbl...
Hi,

Just curious what does the @ system means in c#. Some of the sample codes
i read it written as:

bool bExists = File.Exists(@"c:\\hello.txt");

but i can get the same result as using

bool bExists = File.Exists("c:\hello.txt");

Does @ has special meaning?
Neither of those will work as you've got the @ on the wrong text.

Shawn has explained what @ does so I won't repeat the explanation.

Michael
Jul 19 '06 #5
thi
thanks i got better understanding now....

"thi" <th******@hotmail.comwrote in message
news:OD**************@TK2MSFTNGP03.phx.gbl...
Hi,

Just curious what does the @ system means in c#. Some of the sample codes
i read it written as:

bool bExists = File.Exists(@"c:\\hello.txt");

but i can get the same result as using

bool bExists = File.Exists("c:\hello.txt");

Does @ has special meaning?

Thanks

Jul 19 '06 #6

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

Similar topics

11
by: Troll | last post by:
Hi, This is related to my previous post but I made it much simpler... open (INFILE, "test.txt"); while (<>) { print $_; s/one/two/g; print $_; }
3
by: Falk Fassmann | last post by:
Hello people, I have some problem with Debugging in MS Visual C++. I want to generate a TCP/IP-Socket. The compiling-process is fine but when I debugg the project there's occuring some errors...
75
by: Beni | last post by:
I have been programming in C for about a year now. It sounds silly, but I never took the time to question why a C(or C++ or Java) program execution begins only at the main(). Is it a convention or...
3
by: kathy | last post by:
In my C++.NET Class library project, I called a dll by using: #using "My_Win32_Dll.dll" But when I build the project, I got: "c:\DotNET\C++\C++_Solution\MyClassLib\MyClassLib.h(5): fatal...
23
by: Xah Lee | last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee, 2006-03-15 Let me summarize: The LISP notation, is a functional notation, and is not a...
10
by: Thierry Lam | last post by:
What does the following macro mean, especially the << sign: #define hello(x) (( int64 ) floor( (double) x ) << 32) Thanks Thierry
2
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
15
by: arnuld | last post by:
-------- PROGRAMME ----------- /* Stroustrup, 5.6 Structures STATEMENT: this programmes *tries* to do do this in 3 parts: 1.) it creates a "struct", named "jd", of type "address". 2. it...
4
by: dolphin | last post by:
Hi All I read a .cpp files,find that static void fun(void){......} int main() { .......... } What does this static function mean?Is it the same as the static
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.