adding single quotes  
Author Message
shine46055





PostPosted: Visual C# General, adding single quotes Top

Does anyone know how to add a single quote character in the subject line of an email like this "hello 'XXX YYY' " I've tried every thing, escaping a character, character entities etc but all in vain. Please help. Any suggestion would be greatly appreciated.

Thanks in Advance
Shine



Visual C#4  
 
 
ahmedilyas





PostPosted: Visual C# General, adding single quotes Top

it should work...

string theSubject = "hello 'XXX YYY'";



 
 
RizwanSharp





PostPosted: Visual C# General, adding single quotes Top

Try this:

"hello \'XXX YYY\' "

Put a slash before ', during compilation, comiler will see slash and will ignore it because its an escape sequence in C#.

Best Regards,

Rizwan



 
 
ahmedilyas





PostPosted: Visual C# General, adding single quotes Top

I wouldnt understand why you need a backslash on the single quote. It works fine. It's not a special character for C#/Compiler.

if you are looking to include quote marks (double quotes) then you need a backslash:

MessageBox.Show("\"hi 'XXX'\"");



 
 
Peter Ritchie





PostPosted: Visual C# General, adding single quotes Top

A single quote character "'" and a single quote escape "\'" can be used interchangably:

String text1, text2, text3, text4;

text1 = "'one'";

text2 = "\'one'";

text3 = "\'one\'";

text4 = "'one\'";

System.Diagnostics.Debug.Assert(text1 == text2 && text3 == text4 && text2 == text3);