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 to convert a char to a String?
- Convert String to double in Java
- IOException: The process cannot access the file ‘file path’ because it is being used by another process
- How to resolve “Input string was not in a correct format.” error?
- failed to load resource: the server response with a status 500 (internal server error)
- C# compiler error: “not all code paths return a value”
- How to split a String by space
- C# 2D platformer movement code
- How to remove .html from URL?
- What is the purpose of nameof?
- Convert character to ASCII numeric value in java
- How to replace ” \ ” with ” \\ ” in java
- Why is Dictionary preferred over Hashtable in C#?
- Error: “Cannot modify the return value” c#
- Why am I getting string does not name a type Error?
- The client and server cannot communicate, because they do not possess a common algorithm – ASP.NET C# IIS TLS 1.0 / 1.1 / 1.2 – Win32Exception
- Cannot implicitly convert type ‘customtype’ to ‘othercustomtype’
- Metadata file ‘.dll’ could not be found
- How to convert a Binary String to a base 10 integer in Java
- Easiest way to alter eBay page content/DOM
- Why does var evaluate to System.Object in “foreach (var row in table.Rows)”?
- MSHTML DLL on Windows 10
- Mixing a PHP variable with a string literal
- Unity 2d jumping script
- Hash function for a string
- Read and parse a Json File in C#
- Passing just a type as a parameter in C#
- How to declare session variable in C#?
- C# Print list of string array
- finding the maximum length of lists in c#
- “A project with an Output type of Class Library cannot be started directly”
- Lua read beginning of a string
- Randomize a List
- MVC5 / C# – Cannot perform runtime binding on a null reference
- “A project with an Output type of Class Library cannot be started directly”
- Conversion of a datetime2 data type to a datetime data type results out-of-range value
- JSON.NET Error Self referencing loop detected for type
- Ruby array to string conversion
- entity object cannot be referenced by multiple instances of IEntityChangeTracker. while adding related objects to entity in Entity Framework 4.1
- What does ModelState.IsValid do?
- Why I cannot cout a string?
- How to change string into QString?
- Replace a character at a specific index in a string?
- Destroy an object in C#
- How to remove part of a string?
- How to convert a String to CharSequence?
- How do I convert a String to a BigInteger?
- Converting String to Cstring in C++
- How to compare character ignoring case in primitive types
- What is the simplest regular expression to validate emails to not accept them blindly?
- The provider did not return a ProviderManifestToken string Entity Framework
- Why is HttpContext.Current null?
- Getting selected value of a combobox
- Insert string at specified position
- Add item to Listview control
- Convert Char to String in C
- Windows service start failure: Cannot start service from the command line or debugger [duplicate]
- Displaying DateTime picker instead of Date picker in ASP .NET MVC 5.1/HTML 5 specific
- C# int to byte[]
- Declaration is incompatible with type
- I’m getting the error “stoi is not a member of std” in myprogramminglab [duplicate]
- TypeError: coercing to Unicode: need string or buffer
- How to enumerate an enum
- How to connect to database from Unity