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 [at]
symbol for before a string?

eg:

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

Why can't it just be:

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

Thanks

David
Pietje puk [ Do, 17 April 2008 15:17 ] [ ID #1944350 ]

Re: CSharp @

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 [at]
> symbol for before a string?
>
> eg:
>
> FileInfo myFile = new FileInfo( [at] "c:\Temp\Test\readme.txt");
>
> Why can't it just be:
>
> FileInfo myFile = new FileInfo("c:\Temp\Test\readme.txt"); ?
>
> Thanks
>
> David
Pietje puk [ Do, 17 April 2008 15:29 ] [ ID #1944351 ]

Re: CSharp @

"David" <asd [at] asd.com> wrote in message
news:guWdnfIZ3tOe05rVRVnyhwA [at] 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 [at]
> symbol for before a string?
>
> eg:
>
> FileInfo myFile = new FileInfo( [at] "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");
Leon Mayne [ Do, 17 April 2008 15:26 ] [ ID #1944352 ]

Re: CSharp @

"David" <asd [at] asd.com> wrote in message
news:guWdnfIZ3tOe05rVRVnyhwA [at] brightview.com...

> What's the [at] symbol for before a string?

http://www.c-sharpcorner.com/UploadFile/harishankar2005/verb atim_literals11262005010742AM/verbatim_literals.aspx


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
mark [ Do, 17 April 2008 15:44 ] [ ID #1944356 ]

Re: CSharp @

It states the string is a literal, warts and all. Without the [at] , 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" <asd [at] asd.com> wrote in message
news:guWdnfIZ3tOe05rVRVnyhwA [at] 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 [at]
> symbol for before a string?
>
> eg:
>
> FileInfo myFile = new FileInfo( [at] "c:\Temp\Test\readme.txt");
>
> Why can't it just be:
>
> FileInfo myFile = new FileInfo("c:\Temp\Test\readme.txt"); ?
>
> Thanks
>
> David
NoSpamMgbworld [ Do, 17 April 2008 17:49 ] [ ID #1944370 ]
Microsoft » microsoft.public.dotnet.framework.aspnet » CSharp @

Vorheriges Thema: Set Focus after Postback (vb.net newbie)
Nächstes Thema: Master Page. Why does this happens?