basic question

  • Thread starter Thread starter Mark Fox
  • Start date Start date
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!
 
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
 
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!
!
 
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
 
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!
!>!
!>
!>
!>.
!>
!
 
Back
Top