I need to add a \ symbol to a string.
I can’t find the way to do that, because
@"\" == "\\"
\ is not the correct statement.
EDIT
Actually I am trying to generate SQL query string which contains the ' character. In order to SQL reads it correctly I should represent it like \'. So, my code is something like this:
string query = "SELECT somequery";
query += "\\'";
But when SQL try to execute this query it thinks that query contains exactly \ \\'.
Are you trying to escape the apostrophe (‘) in a SQL string literal? Replace it by two apostrophes (”). The backslash applies to C#, not to SQL.
EDIT:
May be you are looking for:
But consider using SQL parameters in this case, instead of using string operations.
The backslash needs no escaping in SQL: