我正在尝试这样做,但它失败了CChar(“”“)。任何想法我尝试了CChar(”\“”)。它给出错误“字符串常量必须以双引号结束”
Dim arrayWithQuote() As Char = {CChar("a"), CChar("b"), CChar(""")}
答案 0 :(得分:1)
你只需要一个额外的双引号来逃避它(你不使用\
来转义vb中的字符串):
Dim arrayWithQuote() As Char = {CChar("a"), CChar("b"), CChar("""")}
正如蒂姆所指出的,你应该使用字面文字来做这类事情:
Dim arrayWithQuote() As Char = {"a"c, "b"c, """"c}
或者你可以这样做:
Dim arrayWithQuote() As Char = {"a"c, "b"c, Microsoft.VisualBasic.Chr(34)}
答案 1 :(得分:0)
尝试将字符串分隔为: -
Dim arrayWithQuote() As Char = {CChar("a"), CChar("b"), CChar("""")}