1

我正在尝试这样做,但 CChar(""") 失败了。我尝试过 CChar("\"") 的任何想法。它给出了错误“字符串常量必须以双引号结尾”

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

2 回答 2

1

你只需要一个额外的双引号来转义它(你不用\来转义 vb 中的字符串):

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

正如蒂姆指出的那样,您应该使用 char 文字来做这种事情:

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

或者,您可以这样做:

Dim arrayWithQuote() As Char = {"a"c, "b"c, Microsoft.VisualBasic.Chr(34)}
于 2013-09-06T15:43:05.293 回答
0

尝试将字符串分隔为:-

Dim arrayWithQuote() As Char = {CChar("a"), CChar("b"), CChar("""")}
于 2013-09-06T15:43:27.717 回答