string.Replace does not work for quote

Posted by Azhar on Stack Overflow See other posts from Stack Overflow or by Azhar
Published on 2010-06-07T13:49:08Z Indexed on 2010/06/07 13:52 UTC
Read the original article Hit count: 341

Filed under:
|
|

((string)dt.Rows[i][1]).Replace("'", "\'")

I want the result that if any string have quote it change it into slash quote

e.g John's -> John\'s

but the above replace function is not working fine. it results like John\'s

but if we change the code to

((string)dt.Rows[i][1]).Replace("'", "\'") it gives the Result like John's

does change it anyway.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET