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

CSharp @

Hi,

I know this isn't a C# group, but its just a quick one.

As a seasoned C++ developer I'm learning C# as I go along. What's the @
symbol for before a string?

eg:

FileInfo myFile = new FileInfo(@"c:\Temp\Test\readme.txt");

Why can't it just be:

FileInfo myFile = new FileInfo("c:\Temp\Test\readme.txt"); ?

Thanks

David
Jun 27 '08 #1
4 829
S'ok- found out.

Its for treating the '\' marks as '\' marks, not leading characters.

David wrote:
Hi,

I know this isn't a C# group, but its just a quick one.

As a seasoned C++ developer I'm learning C# as I go along. What's the @
symbol for before a string?

eg:

FileInfo myFile = new FileInfo(@"c:\Temp\Test\readme.txt");

Why can't it just be:

FileInfo myFile = new FileInfo("c:\Temp\Test\readme.txt"); ?

Thanks

David
Jun 27 '08 #2
"David" <as*@asd.comwrote in message
news:gu*********************@brightview.com...
Hi,

I know this isn't a C# group, but its just a quick one.

As a seasoned C++ developer I'm learning C# as I go along. What's the @
symbol for before a string?

eg:

FileInfo myFile = new FileInfo(@"c:\Temp\Test\readme.txt");

Why can't it just be:

FileInfo myFile = new FileInfo("c:\Temp\Test\readme.txt"); ?
Because it escapes all the characters in the string. It couldn't be the
second example you gave, it would have to be:

FileInfo myFile = new FileInfo("c:\\Temp\\Test\\readme.txt");

Jun 27 '08 #3
"David" <as*@asd.comwrote in message
news:gu*********************@brightview.com...
What's the @ symbol for before a string?
http://www.c-sharpcorner.com/UploadF..._literals.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #4
It states the string is a literal, warts and all. Without the @, you are
accepting \ as an escape character.

Your second string would fail, as it is not escaping anything valid.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
"David" <as*@asd.comwrote in message
news:gu*********************@brightview.com...
Hi,

I know this isn't a C# group, but its just a quick one.

As a seasoned C++ developer I'm learning C# as I go along. What's the @
symbol for before a string?

eg:

FileInfo myFile = new FileInfo(@"c:\Temp\Test\readme.txt");

Why can't it just be:

FileInfo myFile = new FileInfo("c:\Temp\Test\readme.txt"); ?

Thanks

David

Jun 27 '08 #5

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

Similar topics

0
by: Jonathan Grobe | last post by:
From: Nigel Perry <nigel@cosc.canterbury.ac.nz> Newsgroups: news.announce.newgroups,news.groups Subject: RFD: comp.std.csharp Date: Tue, 08 Jul 2003 00:26:01 +0000 REQUEST FOR DISCUSSION (RFD)...
7
by: Eric Gunnerson | last post by:
If you would like to see this group created, please reply to this post, making sure you leave news.groups on the newsgroups line. "Nigel Perry" <nigel@cosc.canterbury.ac.nz> wrote in message...
5
by: Mr. x | last post by:
Hello, where can I find csharp tutorial/help/samples. *.chm file is preffered. Thanks :)
8
by: Nicolas | last post by:
How do I do a RaiseEvent in csharp I'm ok in VB but csharp confused me a lot. ******* code ******** private FileSystemWatcher watcher = new FileSystemWatcher(); public delegate void...
4
by: light_wt | last post by:
Hi I am taking the 2555 class and a lot of the material is over my head. I don't like the MS's book because there is no step-by-step on interacting with the VS.NET Is there good free resource...
2
by: anand | last post by:
Hi All, Are ownerdraw buttons supported in C# ? I have an active X control which I would like to use in CSharp. Buttons have a style BS_OWNERDRAW, and to do custom drawing you have to...
7
by: Peter Smirnov | last post by:
Sorry for this newbie question but as far as I heard one need at least VisualStudio to develop CSharp applications. Is this correct? Are there otherwise some command line tools like javac.exe and...
1
by: Preston | last post by:
hello all... My friend using vb.net made a DLL file which contains a Property Kkk(ByVal key As Object) in it, I use CSharp and reference this DLL file, but in csharp object browser, there is no...
2
by: news.microsoft.com | last post by:
Hi: I work in Csharp's parser files by LEX/YACC.Now I have only CSharp-lex.l and CSharp.y file,but they not have CSharp'comment Parse. this is a part of CSharp-lex.l. ........................
2
by: Karl | last post by:
Hi all, I'm reasonably new to csharp so you have to forgive me asking what may be a stupid question... As I said, I'm new to CSharp but in VB I was able to click anywhere on a DataGridView...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.