Quotes in C#

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I have the following code:

StringBuilder paper = new StringBuilder();
paper.AppendLine(string.Format("<div id=""Document""
class=""ScribdIPaper""></div>", client));

In VB.NET "" in a string translates into a ".

In C# this is not working. How can I make this render the "?

Thanks,
Miguel
 
shapper said:
Hello,

I have the following code:

StringBuilder paper = new StringBuilder();
paper.AppendLine(string.Format("<div id=""Document""
class=""ScribdIPaper""></div>", client));

In VB.NET "" in a string translates into a ".

In C# this is not working. How can I make this render the "?

paper.AppendLine(string.Format(
"<div id=\"Document\" class=\"ScribdIPaper\"></div>", client));
 
Hello,

I have the following code:

StringBuilder paper = new StringBuilder();
paper.AppendLine(string.Format("<div id=""Document""
class=""ScribdIPaper""></div>", client));

In VB.NET "" in a string translates into a ".

In C# this is not working. How can I make this render the "?

Thanks,
Miguel

use \"

-Cnu
 
shapper said:
Hello,

I have the following code:

StringBuilder paper = new StringBuilder();
paper.AppendLine(string.Format("<div id=""Document""
class=""ScribdIPaper""></div>", client));

In VB.NET "" in a string translates into a ".

In C# this is not working. How can I make this render the "?

Thanks,
Miguel

You either escape the quotation mark using a backslash:

paper.AppendLine(string.Format("<div id=\"Document\"
class=\"ScribdIPaper\"></div>", client));

Or use an @-delimited string:

paper.AppendLine(string.Format(@"<div id=""Document""
class=""ScribdIPaper""></div>", client));


There is something missing in your code, though. There is no format
specifier in the format string, so the client value isn't included in
the string.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top