You can use the @
symbol in front of a string
to form a verbatim string literal:
string query = @"SELECT foo, bar FROM table WHERE id = 42";
You also do not have to escape special characters when you use this method, except for double quotes as shown in Jon Skeet’s answer.
Related Posts:
- How can I convert String to Int?
- Convert int to string?
- Converting string to byte array in C#
- How can I add ” character to a multi line string declaration in C#?
- C# List
to string with delimiter - Convert a list of strings to a single string
- C#: how to get first char of a string?
- How to initialize a list of strings (List
) with many string values - What does {0} mean when found in a string in C#?
- C# – Illegal characters in path
- Getting The ASCII Value of a character in a C# string
- How can I fix the error : “Unreachable Code Detected”
- C# – How to convert string to char?
- Escape double quotes in a string
- What’s the @ in front of a string in C#?
- Creating a comma separated list from IList
or IEnumerable - Best way to repeat a character in C#
- Fastest way to remove first char in a String
- Checking if a string array contains a value, and if so, getting its position
- Substring index and length must refer to a location within the string
- Case insensitive ‘Contains(string)’
- Most efficient way to remove special characters from string
- Is there an equivalent to the Scanner class in C# for strings?
- Adding a newline into a string in C#
- How to format a string as a telephone number in C#
- How to convert UTF-8 byte[] to string
- .NET String.Format() to add commas in thousands place for a number
- How would you count occurrences of a string (actually a char) within a string?
- C# equivalent to Java’s charAt()?
- What is a quick way to force CRLF in C# / .NET?
- Check if a string is a palindrome
- Convert string to decimal, keeping fractions
- What is the difference between String and string in C#?
- Convert JSON String to JSON Object c#
- Convert an array to string
- Unrecognized escape sequence for path string containing backslashes
- How do I lowercase a string in Python?
- How do I convert a String to an int in Java?
- Convert HTML to PDF in .NET
- How to show a loading gif while an APi is being called in xamarin android?
- ImageMagick creating blank transparent square(s) according to width
- How to format strings in Java
- How do I get a substring of a string in Python?
- Substring in excel
- .Net 4.8 Support for Windows 10 ends in 26 days?
- Does Python have a string ‘contains’ substring method?
- Why the switch statement cannot be applied on strings?
- How does strtok() split the string into tokens in C?
- Convert bytes to a string
- Java – Convert integer to string [duplicate]
- Replacing instances of a character in a string
- Changing one character in a string
- How to read a file line-by-line into a list?
- What is lexicographical order?
- What exactly does += do in python?
- strip(char) on a string
- How do I generate a random int number?
- Why has the int32 type a maximum value of 2³¹ − 1? [duplicate]
- How to convert string to char array in C++?
- What is a NullReferenceException, and how do I fix it?
- How can I convert a std::string to int?
- How to convert list to string [duplicate]
- Easiest way to convert int to string in C++
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
- How to check whether a string contains a substring in JavaScript?
- Check if a string has a certain piece of text [duplicate]
- Converting integer to string in Python
- Reverse a string in Python
- How do I get a random YouTube video with the YouTube API?
- An existing connection was forcibly closed by the remote host
- How to split a string in Java
- C# HttpClient An existing connection was forcibly closed by the remote host
- How do I compare strings in Java?
- How to replace all occurrences of a string in JavaScript
- How do I compare two strings in python?
- std::string to char*
- How to convert a string to an integer in JavaScript?
- How to convert string to char array in C++?
- What is a NullReferenceException, and how do I fix it?
- How to convert an int to string in C?
- C++ — expected primary-expression before ‘ ‘
- How can I do string interpolation in JavaScript?
- How to convert a char to a String?
- What is a PDB file?
- Regex not operator
- How to convert/parse from String to char in java?
- C++ string to double conversion
- How do I make the first letter of a string uppercase in JavaScript?
- Reverse a string in Java
- What is the { get; set; } syntax in C#?
- working of \n in python [duplicate]
- ValueError: could not convert string to float: id
- How do I make the first letter of a string uppercase in JavaScript?
- Regex not operator
- Print string to text file
- Unexplained crashes related to ntdll.dll
- Reverse a string in Java
- What is a string of hexadecimal digits?
- Best way to convert string to bytes in Python 3?
- Pythonic way to create a long multi-line string