Include quotation marks in String variable value

1

I would like to know how do I declare a String variable in which the value has quotation marks in Visual Basic .NET?

For example:

Public frase As String = "E ele disse: -"Olá a todos!""

Is there any escape expression for Visual Basic to understand that the quotation marks in the variable value are part of the value, and are not ending the variable declaration?

    
asked by anonymous 01.06.2018 / 06:40

2 answers

1

How to include double quotation marks as text in a String in Visual Basic is putting two followed, thus "" .

Your sample code should become:

Public frase As String = "E ele disse: -""Olá a todos!"""

See this example in .Net Fiddle

You can also see an example of this pattern in the documentation

    
01.06.2018 / 11:18
0

Yes, there is a way. You should use \ before the " For example:

String Frase = " O cachorro é \"BRAVO\"  ";
    
01.06.2018 / 06:50