How to do a verbatim string literal in VB.NET?
All string literals in VB.NET are verbatim string literals. Simply write
Dim str As String = "c:\folder1\file1.txt"
VB.NET doesn't support inline control characters. So backslashes are always interpreted literally.
The only character that needs to be escaped is the double quotation mark, which is escaped by doubling it, as you do in C#
Dim s As String = """Ahoy!"" cried the captain." ' "Ahoy!" cried the captain.
@MarkJ already pointed this out in @Jon Skeet's post.
VB.Net supports this abomination feature, if you absolutely need to use a verbatim via an inline XML Literal.
Consider Caching the String! Don't evaluate this every time...
Imports System.Xml.Linq
Dim cmdText as String = <![CDATA[
SELECT
Field1, Field2, Field3
FROM table
WHERE Field1 = 1
]]>.Value
[edit 2015-Jan-5]
VB14 / VS2015 supports multi-line strings without any shenanigans.
Dim cmdText as String = "
SELECT
Field1, Field2, Field3
FROM table
WHERE Field1 = 1"