By using our mini forum, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy

Q: How to show quotes in strings in C#?

+5 votes

I need to declare two string variables and assign them with following value:
The "use" of quotations causes difficulties.


It needs to be done in two different ways: with and without using quoted strings.

The output must be the same - only the way must be different for each printed line.

The "use" of quotations causes difficulties.
The "use" of quotations causes difficulties.


asked in C# category by user Jolie Ann
edited by user golearnweb

1 Answer

+1 vote
Best answer
using System;

class QuotesInStrings
    static void Main()
        string a = @"The ""use"" of quotations causes difficulties.";
        string b = "The \"use\" of quotations causes difficulties.";


First use @ in front of the opening quote - bear in mind the double "" before and after the use word!

Second: use the escape \ to show up the inner ""...

answered by user john7
selected by user golearnweb