basic question

M

Mark Fox

Hello,

I've noticed in some sample code that sometimes
people use the @ before a string when concatenating
them. Example:

string filePath = Appl.Request.PhysicalApplicationPath +
@"bin\" + asmname + ".dll";

Why is this done? What is the difference between using
the @ before the string and not using it? Thanks for
your help!
 
K

Karsten Grombach

hi mark,
if you add the @ before a string the escape sequences are ignored. this has
nothing to do with concatenating.
i.e.
@"bin\" + asmname + ".dll";
and
"bin\\" + asmname + ".dll";
result in the same ..

the 2 following statments result in : the boy said "Hello".
@"the boy said ""Hello""."
"the boy said \"Hello\"."

Hope this helps
Karsten
 
Y

Yan-Hong Huang[MSFT]

Hello Mark,

@-quoted string literals start with @ and are enclosed in double quotation marks. For example:

@"good morning" // a string literal

The advantage of @-quoting is that escape sequences are not processed, which makes it easy to write, for example, a fully
qualified file name:

@"c:\Docs\Source\a.txt" // rather than "c:\\Docs\\Source\\a.txt"

To include a double quotation mark in an @-quoted string, double it:
@"""Ahoy!"" cried the captain." // "Ahoy!" cried the captain.

Thanks.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!Content-Class: urn:content-classes:message
!From: "Mark Fox" <[email protected]>
!Sender: "Mark Fox" <[email protected]>
!Subject: basic question
!Date: Wed, 23 Jul 2003 00:07:18 -0700
!Lines: 12
!Message-ID: <[email protected]>
!MIME-Version: 1.0
!Content-Type: text/plain;
! charset="iso-8859-1"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: Microsoft CDO for Windows 2000
!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!Thread-Index: AcNQ6Q4O+P0RyAbqSfOMJUE4aJxN3A==
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!Path: cpmsftngxa06.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:161258
!NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
!
!Hello,
!
! I've noticed in some sample code that sometimes
!people use the @ before a string when concatenating
!them. Example:
!
!string filePath = Appl.Request.PhysicalApplicationPath +
!@"bin\" + asmname + ".dll";
!
!Why is this done? What is the difference between using
!the @ before the string and not using it? Thanks for
!your help!
!
 
M

Mark Fox

Thank you so much for explaining this. I understand what
it does now!
-----Original Message-----
Hello Mark,

@-quoted string literals start with @ and are enclosed
in double quotation marks. For example:
@"good morning" // a string literal

The advantage of @-quoting is that escape sequences are
not processed, which makes it easy to write, for example,
a fully
 
Y

Yan-Hong Huang[MSFT]

Hello,

You are welcome. :) Thanks for participating in community.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!Content-Class: urn:content-classes:message
!From: "Mark Fox" <[email protected]>
!Sender: "Mark Fox" <[email protected]>
!References: <[email protected]> <[email protected]>
!Subject: RE: basic question
!Date: Wed, 23 Jul 2003 03:59:58 -0700
!Lines: 74
!Message-ID: <[email protected]>
!MIME-Version: 1.0
!Content-Type: text/plain;
! charset="iso-8859-1"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: Microsoft CDO for Windows 2000
!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!Thread-Index: AcNRCY54Gk5IwRKnTeGHtC7K60Mctg==
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!Path: cpmsftngxa06.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:161313
!NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
!
!Thank you so much for explaining this. I understand what
!it does now!
!
!>-----Original Message-----
!>Hello Mark,
!>
!>@-quoted string literals start with @ and are enclosed
!in double quotation marks. For example:
!>
!>@"good morning" // a string literal
!>
!>The advantage of @-quoting is that escape sequences are
!not processed, which makes it easy to write, for example,
!a fully
!>qualified file name:
!>
!>@"c:\Docs\Source\a.txt" // rather
!than "c:\\Docs\\Source\\a.txt"
!>
!>To include a double quotation mark in an @-quoted
!string, double it:
!>@"""Ahoy!"" cried the captain." // "Ahoy!" cried the
!captain.
!>
!>Thanks.
!>
!>Best regards,
!>Yanhong Huang
!>Microsoft Online Partner Support
!>
!>Get Secure! - www.microsoft.com/security
!>This posting is provided "AS IS" with no warranties, and
!confers no rights.
!>
!>--------------------
!>!Content-Class: urn:content-classes:message
!>!From: "Mark Fox" <[email protected]>
!>!Sender: "Mark Fox" <[email protected]>
!>!Subject: basic question
!>!Date: Wed, 23 Jul 2003 00:07:18 -0700
!>!Lines: 12
!>!Message-ID: <[email protected]>
!>!MIME-Version: 1.0
!>!Content-Type: text/plain;
!>! charset="iso-8859-1"
!>!Content-Transfer-Encoding: 7bit
!>!X-Newsreader: Microsoft CDO for Windows 2000
!>!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!>!Thread-Index: AcNQ6Q4O+P0RyAbqSfOMJUE4aJxN3A==
!>!Newsgroups: microsoft.public.dotnet.framework.aspnet
!>!Path: cpmsftngxa06.phx.gbl
!>!Xref: cpmsftngxa06.phx.gbl
!microsoft.public.dotnet.framework.aspnet:161258
!>!NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
!>!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
!>!
!>!Hello,
!>!
!>! I've noticed in some sample code that sometimes
!>!people use the @ before a string when concatenating
!>!them. Example:
!>!
!>!string filePath = Appl.Request.PhysicalApplicationPath
!+
!>!@"bin\" + asmname + ".dll";
!>!
!>!Why is this done? What is the difference between using
!>!the @ before the string and not using it? Thanks for
!>!your help!
!>!
!>
!>
!>.
!>
!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top