Search code examples
c#console.writeline

C# Console.WriteLine but text contains ""


I want to write something with Console.WriteLine, but the text contains "". Example:

Console.WriteLine("example: "this is an example" example");

How to avoid this problem?

I tried '' and other symbols, but it didn't work


Solution

  • Use the backslash character to mark the quotations, as shown:

    Console.WriteLine("example: \"this is an example\" example");
    

    This is used in languages to mark special characters, in this case marking the quotation so that it doesn't end the string prematurely.