StringBuilder and C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the best way of creating the staement below in C#? StringBuilder will not accept the string as stated. I've tried several variations of string concatenation but still get errors
StringBuilder postData = new StringBuilder("<CABDETAILS CabNumber=""43877"" CabSKU=""6633"" ExpDate=""0106"" Postal=""78052"" />"); Dont want to create a separate xml file

Thank
Jacob
 
You basicly had it, you just needed the escape character


System.Text.StringBuilder postData = new
System.Text.StringBuilder("<CABDETAILS CabNumber=\"43877\" CabSKU=\"6633\"
ExpDate=\"0106\" Postal=\"78052\" />");


Jacob said:
What is the best way of creating the staement below in C#? StringBuilder
will not accept the string as stated. I've tried several variations of
string concatenation but still get errors.
StringBuilder postData = new StringBuilder("<CABDETAILS
CabNumber=""43877"" CabSKU=""6633"" ExpDate=""0106"" Postal=""78052"" />");
Dont want to create a separate xml file.
 
Thanks Kirk
What if I have something like "Boston\ivr" in the expression string? Since "\" is the escape character, How do I handle that
Jaco
 
Jacob,

try using the @ symbol - it causes the compiler to ignore escape characters.

Something like this to create and initialize the StringBuilder object, then
extract the characters to investigate:

StringBuilder str = new StringBuilder( @"Boston\ivr");
char [] chrs = str.ToString().ToCharArray();

regards
roy fine


Jacob said:
Thanks Kirk-
What if I have something like "Boston\ivr" in the expression string? Since
"\" is the escape character, How do I handle that?
 
Jacob said:
Thanks Kirk-
What if I have something like "Boston\ivr" in the expression string? Since "\" is the escape character, How do I handle that?
Jacob

"Boston\\ivr"
 
Back
Top