سؤال

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