Adding a string that has quotes in it to a StringBuilder

I have a string builder object and I am appending some values to it, one of the values I need to add is this:

<Literal datatypeIRI="&rdf;PlainLiteral">

but when I copy-paste it and add it to the stringbuilder object, it gives error and thinks that sring parameter is not completed yet...I also tried to put a "@" at the beginning of it, but still the same problem.

Answers


" characters need to be escaped. For normal strings, use \", for @ strings use "".

e.g. "<Literal datatypeIRI=\"&rdf;PlainLiteral\">"


You need to escape the embedded ":

"<Literal datatypeIRI=\"&rdf;PlainLiteral\">"

Or:

@"<Literal datatypeIRI=""&rdf;PlainLiteral"">"

Need Your Help

Multiple keyboards and low-level hooks

c# winapi keyboard hardware hook

I have a system where I have multiple keyboards and really need to know which keyboard the key stroke is coming from. To explain the set up:

Need a free datepicker for ASPX

asp.net date datepicker

What is the best FREE Datepicker that can be dropped into an ASPX application?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.