Solved

Quotes in a string

Posted on 2009-05-08
2
378 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 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