Including " Quotation marks in strings.

I am trying to include quotation marks in a string, and struggling. The string should be;
"VOLT"
However if I define the string as I would normally;

public string VoltString = " "VOLT" ";

errors are thrown since the compiler sees the first two quotation marks and thinks that anything between them is the string, then throws an error on the reminder of the line VOLT" ";.
One way around this would be if I could remove the quotation marks again though the same issue arises since the code would be;

char[] trimChars = {"""};
string voltString = voltString.Trim(trimChars);


and again I end up with three quotation marks and the compiler seeing only the first two.

Does anybody know of any way for me to either include quotation marks in strings defined in the code, or remove quotation marks from a text box string when I need to use the same piece of information less the quotation marks later

Thank you.



P.H.



Answer this question

Including " Quotation marks in strings.

  • sneakBeats

    You are always welcome :)

    Best Regards,



  • WEE3

    Thank you
    Peter H.

  • RPagels

    Use this:

    public string VoltString = "\"VOLT\"";

    or

    public string VoltString = @""VOLT"";

    I hope this will help!

    Best regards,



  • Including " Quotation marks in strings.