문제

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