I am trying to do this but it fails with the CChar("""). Any ideas I tried CChar("\""). It gives the error "String constants must end with a double quote"

Dim arrayWithQuote() As Char = {CChar("a"), CChar("b"), CChar(""")}
有帮助吗?

解决方案

You just need an extra double quote to escape it (you don't use \ to escape a string in vb):

Dim arrayWithQuote() As Char = {CChar("a"), CChar("b"), CChar("""")}

As Tim Pointed out you should use char literals to do this sort of thing:

Dim arrayWithQuote() As Char = {"a"c, "b"c, """"c}

Alternatively you could do this:

Dim arrayWithQuote() As Char = {"a"c, "b"c, Microsoft.VisualBasic.Chr(34)}

其他提示

Try delimiting the string as:-

Dim arrayWithQuote() As Char = {CChar("a"), CChar("b"), CChar("""")}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top