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

@ symbol and double quotation marks

string str = @""";
string str = """;
Both of them are syntactically wrong. But I dont exactly know why.
How does the compiler/interpreter process the two definitions above?
when the compiler encounters [@"], whether will it jump to the end of the code line to find [;] or just process the line left to right?
Dec 22 '09 #1

✓ answered by Plater

Using the @ sign in C# tells the compiler to ignore any string escape sequences. So using \r\n or \t or \" will no longer work. I believe it is only in C#
The double " I think is only in VB(NET)

C# example
Expand|Select|Wrap|Line Numbers
  1. string mydir = @"c:\temp\";
  2. string samedir ="c:\\temp\\";
  3. //both are correctly escaped
  4.  

3 3555
ssnaik84
149 100+
compiler first check semi-colon (;) that is terminator symbol of statement.
then takes value in between first two double quote (")

if you want to use extra double quotes, then use backward slash (\) before extra double quote (")

Expand|Select|Wrap|Line Numbers
  1. string str = "\"\"";
Dec 22 '09 #2
Thanks.But I dont agree with u fully.For[string str = """;], compiler seems to check semi-colon to find the end position of the code line. But for [string str = @""";],due to the At sign, this code line in VS2005 together with several other code lines below are all turned to red(red color means syntactically wrong in VS2005 IDE).
Obviously, compiler consider [string str = @""";] and several lines below it to be a single line,and the fire semi-colon( that's the one in[ @""";]) is considered to be a normal char. That's why @ confused me. It seems that "@" doesn't know how to deal with the string follows him when the string contains extra double quotes.
Dec 22 '09 #3
Plater
7,872 Expert 4TB
Using the @ sign in C# tells the compiler to ignore any string escape sequences. So using \r\n or \t or \" will no longer work. I believe it is only in C#
The double " I think is only in VB(NET)

C# example
Expand|Select|Wrap|Line Numbers
  1. string mydir = @"c:\temp\";
  2. string samedir ="c:\\temp\\";
  3. //both are correctly escaped
  4.  
Dec 22 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

63
by: Tristan Miller | last post by:
Greetings. Do any popular browsers correctly support <q>, at least for Western languages? I've noticed that Mozilla uses the standard English double-quote character, ", regardless of the lang...
4
by: Thomas Miskiewicz | last post by:
Hi! Is using of a double quotation mark with a URL a problem? For example: http://myserver.com/query?field1=something&field2=test&params="field1=test1"+"field2=test2" Regards Thomas
4
by: NickName | last post by:
Hi, It seems to be simple, however, it stumbles me. how to replace all the double quotes (") within the following sentence (or a column) with single quotes ('), colA = this is a freaking...
18
by: gabriel | last post by:
greetings, I am currently working on a website where I need to print the Euro symbol and some "oe" like in "oeuvre". If I choose this : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
7
by: Paradigm | last post by:
I am trying to create a recordset where some text fields are matching. The problem is that some of the text fields contain quotation marks. I have tried to create the sql string using replace eg....
1
by: kudeep | last post by:
Hi everyone i m new here. I have made an web application where user enter message and clicks on the SUBMIT button. Clickin on the SUBMIT button will execute a INSERT statement. Program works...
0
by: Savvas | last post by:
Hi, I have hundrends of CSV (comma delimited) files and need to check only the first column (text format) whether is correct or not. Example of incorrect column is the following: "The Product...
32
by: SAL | last post by:
Hello, I do not have any trouble declaring string values except when it comes to directory path's. Why does C# implicitly put a @ symbol at the being of a String value that has been declared...
31
by: The Bicycling Guitarist | last post by:
Hi. For many years I have been using &quot; for double quotation marks in the HTML code, but the opening and closing quotation marks render the same in my browser. I'm considering going through and...
1
by: U Aye Thein | last post by:
I found in internet how to solve single quotation mark in string and how to solve double quotation mark in string but my string may be contained single quote or double quote. How to write an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.