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

double quote in verbatim string

Hi,

is there a way to put " (double quote) into a verbatin
string?

thank you
Nov 16 '05 #1
4 24245
Use \"
as follows:

string myString = "This string has \"quotes\" in it";
"fred" <an*******@discussions.microsoft.com> wrote in message
news:18****************************@phx.gbl...
Hi,

is there a way to put " (double quote) into a verbatin
string?

thank you

Nov 16 '05 #2
Also, remember you can use @ if you don't want to have to escape certain
characters (e.g. backslashes)

Thus, @"C:\Temp" is equivalent to "C:\\Temp" as both are interpreted as
C:\Temp. That won't help you for double-quotes, of course, since an
unescaped double-quote will be interpreted as a delimiter. So you have to
escape it just as Pete indicates. But the @ is useful for other string
literals.

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.

"Pete Davis" <pd******@NOSPAM.hotmail.com> wrote in message
news:m6********************@giganews.com...
Use \"
as follows:

string myString = "This string has \"quotes\" in it";
"fred" <an*******@discussions.microsoft.com> wrote in message
news:18****************************@phx.gbl...
Hi,

is there a way to put " (double quote) into a verbatin
string?

thank you


Nov 16 '05 #3
Kai Brinkmann [MSFT] <ka******@online.microsoft.com> wrote:
Also, remember you can use @ if you don't want to have to escape certain
characters (e.g. backslashes)

Thus, @"C:\Temp" is equivalent to "C:\\Temp" as both are interpreted as
C:\Temp. That won't help you for double-quotes, of course, since an
unescaped double-quote will be interpreted as a delimiter. So you have to
escape it just as Pete indicates. But the @ is useful for other string
literals.


No, you *don't* have to escape it that way - you can embed double
quotes in verbatim string literals (which was what the OP was asking
about) by doubling them up:

string x = @"before quote "" after quote";

--
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
fred <an*******@discussions.microsoft.com> wrote:
is there a way to put " (double quote) into a verbatin
string?


See http://www.pobox.com/~skeet/csharp/s....html#literals

(Basically, double the quote.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5

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

Similar topics

1
by: Ernie | last post by:
Hi, I am learning swig to use C codes from Python. Here is the swig file mvf.i: %module mvf %include "carrays.i" %array_class(double, doubleArray); %typemap(out) double, float "$result =...
4
by: ouch | last post by:
Hi Everyone, Is there any way to remove the "@" from a verbatim string? I've tried the .remove(int, int) method, but it doesn't work. Thanks ouch
9
by: Steven Blair | last post by:
Hi, I need to update a DB Table (MySQL 4.0) with a string representing a directory path (C:\Temp\In) but cannot get C# to do this. I take the string value from a textbox (myStr = myText.Text)...
1
by: fred | last post by:
Hi, is there a way to put " (double quote) into a verbatin string? thank you
6
by: G. | last post by:
This is an obvious bug in the String.Replace function: //load a XML string into a document XmlDocument doc = new XmlDocument(); doc.LoadXml("<test id='' />"); //Obtain the string...
8
by: Fred | last post by:
Hello, Is there a way to read values from the registry as regular instead of verbatim? Regards, Fred
3
by: Ant | last post by:
Hi, how do you output a string that will be seen with double quotatios? I'd like to display: This is my "Value". by doing something like: string op = "This is my " + " +...
2
by: =?Utf-8?B?QWFyb24=?= | last post by:
Hi, I'm having a tricky problem where I want to accept a regular expression pattern from user input but can't get teh escape characters to be prcoessed correctly. If I take the same pattern and...
4
rhitam30111985
by: rhitam30111985 | last post by:
Hi all ... i have a tricky problem.. cant seem to find a solution to it : using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.