Solved

Ignore a quote.

Posted on 2006-07-21
3
258 Views
Last Modified: 2010-04-16
I have a tough one, I'm replacing a text string with "blank" BUT, the text string contains a quote so I'm getting a build error that is expecting a )..

string results = sb.ToString().Replace("<PolicyDataSet xmlns="http://www.microtrends.net/PolicyDataSet.xsd>"","")
I can't escape the quote because then it doesn't replace the striing because it's not exact...

How can I get it to work, any thoughts?
0
Comment
Question by:boukaka
3 Comments
 
LVL 7

Accepted Solution

by:
whatsit2002 earned 500 total points
ID: 17155228
It looks like your quote is in the wrong place. You should put your quotes inside of the brackets like:
<PolicyDataSet xmlns="http://www.microtrends.net/PolicyDataSet.xsd">

Not:
<PolicyDataSet xmlns="http://www.microtrends.net/PolicyDataSet.xsd>"

So, it looks to me that your issue is not escaped double quotes, but misplaced double quotes. The above code would look like:

string results = sb.ToString().Replace("<PolicyDataSet xmlns=\"http://www.microtrends.net/PolicyDataSet.xsd\">","")

Thanks.

Jason
0
 
LVL 6

Expert Comment

by:dorothy2
ID: 17155333
You wouldn't have this problem if the xmlns attribute had single quotes rather than double.

StringBuilder sb = new StringBuilder("This is a test. <PolicyDataSet xmlns='http://www.microtrends.net/PolicyDataSet.xsd'> This is the end of the test");
Console.WriteLine("Before: " + sb.ToString());
string results = sb.ToString().Replace("<PolicyDataSet xmlns='http://www.microtrends.net/PolicyDataSet.xsd'>","");
Console.WriteLine("After: " + results);


Can you make this change easily? If not, you could use regular expressions to change the double quotes to single quotes before you call Replace().

Dorothy
0
 

Author Comment

by:boukaka
ID: 17155811
I moved the quote and it worked perfectly!!! Thank you so much, I was going insane.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio 2013 debugging 2 35
Syntax error 9 45
Greetings C# program 17 57
C# parent child form 5 19
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now