Solved

Quotes in a string

Posted on 2009-05-08
2
377 Views
Last Modified: 2013-12-17
When a printer name is passed to Adobe it needs to quotes around it if the string contains blanks.  This two line program shows that in order to get the desired quote mystery slashs are inserted.  I have tried similar things with char[] with no better results.
char ch = '"';
string test = ch + "my string" + ch;
 
Expected result is "my string", actual result is "\my string\".

Open in new window

0
Comment
Question by:wilfordrocks
2 Comments
 
LVL 7

Accepted Solution

by:
alexpercsi earned 500 total points
ID: 24336817
This is strange.

Generally when I need to insert quotes in a string I just prefix them with the \ character which is the escape operator. It does not show up in the final string.
Try this and tell me how it works out.
string test = "\"my string\"";

Open in new window

0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 24337121
let me guess ... you determined that it was \"mystring\" by using the debugger? most likely putting your mouse over the variable?

The debugger shows you strings in escaped format...


Greg
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question