How to include \" in a string

2019-01-09 18:00发布

问题:

How do I include the " character in a string.

For example said = "John said "Hi""

回答1:

There are also a set of Control Characters available:

Try

Dim s as String = "John said " & ControlChars.Quote & "Hi" & ControlChars.Quote

I find this much more readable than multiple quotes stacked together.



回答2:

You need to double up the quotes to escape them in VB

e.g. said = "John said ""Hi"""



回答3:

Add Chr(34) to the string!

Something like... Console.Write("Hello " + Chr(34) + "World" + Chr(34))



回答4:

In VB.NET you must use 2 quotes: "John Said ""Hi"""