473,396 Members | 1,933 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,396 software developers and data experts.

This one just caught me by suprise.

This

Console.WriteLine(@"sl["B"]={0}", sl["B"]);

causes a syntax error.

How do I include the quote (") in a verbatum string? Leave off the @ and
backslash the quotes?
Nov 16 '05 #1
4 950
Yes.

Dale Preston

"web1110" <we***@comcast.net> wrote in message
news:Ob********************@comcast.com...
This

Console.WriteLine(@"sl["B"]={0}", sl["B"]);

causes a syntax error.

How do I include the quote (") in a verbatum string? Leave off the @ and
backslash the quotes?

Nov 16 '05 #2

"web1110" <we***@comcast.net> wrote in message
news:Ob********************@comcast.com...
This

Console.WriteLine(@"sl["B"]={0}", sl["B"]);

causes a syntax error.

How do I include the quote (") in a verbatim string? Leave off the @ and
backslash the quotes?


Or I think you can write the quote twice.

Nov 16 '05 #3
web1110 <we***@comcast.net> wrote:
This

Console.WriteLine(@"sl["B"]={0}", sl["B"]);

causes a syntax error.

How do I include the quote (") in a verbatum string? Leave off the @ and
backslash the quotes?


Double the quotes:

Console.WriteLine ("sl[""B""]={0}", sl["B"]);

Frankly though, I think it's more readable just to use a normal
literal.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
Or for readability you could use
string str = string.Format("sl['B']={0}",sl["B"]);
str = str.Replace("'","\"");

On Tue, 22 Mar 2005 07:24:17 -0000, Jon Skeet [C# MVP]
<sk***@pobox.com> wrote:
web1110 <we***@comcast.net> wrote:
This

Console.WriteLine(@"sl["B"]={0}", sl["B"]);

causes a syntax error.

How do I include the quote (") in a verbatum string? Leave off the @ and
backslash the quotes?


Double the quotes:

Console.WriteLine ("sl[""B""]={0}", sl["B"]);

Frankly though, I think it's more readable just to use a normal
literal.


Nov 17 '05 #5

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

Similar topics

21
by: Jenski182 | last post by:
Is this from a good coder? or a rubbish one? Whichever way, it was paid for his services, just want to know if its worth while.... Thanks Jen x #include <iostream.h> #include <conio.h>
7
by: Jon Maz | last post by:
Hi All, The following code throws a "CS0020: Division by constant zero Exception". I would have expected to see a nice, friendly "caught an exception" written to the screen. Can anyone...
5
by: cj | last post by:
Normally, a dotNET application will throw an exception when something goes wrong, and the exception can be caught easily and reported to the user. However, users have been reporting that our...
3
by: will | last post by:
Hi all. I've got an question about how to catch an exception. In Page_Load, I place a DataGrid, dg1, into edit mode. This will call the method called GenericGridEvent. GenericGridEvent will call...
2
by: James Cooke | last post by:
Hi all, I want to catch a duplicate key exception. I do not want to provide that verbose message from the MSSQL server - I would put a user friendly message out, like "The item you have added...
52
by: Julie | last post by:
I'm supporting an application at work. Below are some code segments that I can't understand how they work. First let me say, I would never code this standard. I'm just really creeped out that it...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
30
by: HangEveryRepubliKKKan | last post by:
Ahahahaha.. Lets see if I get this Demented Lintard reasoning right. Vista is a failure becuase after 300 days after it's release, it only has 7.5% of the OS market while the Lintard OS, is a...
16
by: HillBilly | last post by:
This is freaking me out. I'm using Membership and trying to determine if the database is online. The GetConnectionString( ) method returns a connection string as expected but not when used in the...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.