How to represent a quote within a string in C#
Posted on 12/8/2006 3:49:34 AM
in #ASP.NET 2.X
Hi/P>
A very common problem people come-up with while working with string data type is how to work with special character. A number of characters have been labeled as special characters. How would you represent a quote within a string, since the compiler interprets a quote as the beginning or end of the string? Whenever you want to use one of these special characters you need to use a technique known as escaping the character./B>/P>
Here is a list of the string that needs to be used for the purpose of this special character./P>
\n = New Line \r = Carriage return \r\n = Carriage return and New line \” = Quotation mark \\ = Backlash character \t = Tab/P>
[Note: Even though escaped characters involve two characters (backslash \ plus the escaped character) the compiler treats the sequence as one character. That means that \n is a single character and the same is true for \", \\, etc]/SPAN> /o:p>/P>
Hope this helps Thanks Vikram/P>
|
Posted on 10/13/2007 2:12:42 PM
write in textBox1.Text alabala ' xyz " 1 23
string s=textBox1.Text;
convert s to alabala \' \"123 if you can in C sharp.
/p>
|