How to declare a string with double quote substrings in C#

2 Answers

0 votes
using System;

class Program
{
    static void Main()
    {
        string str = "This is a string with \"double-quoted substring1\", and \"double-quoted substring2\" inside.";
        
        Console.WriteLine(str);
    }
}



/*
run:

This is a string with "double-quoted substrings1", and "double-quoted substrings2" inside.

*/

 



answered May 12, 2025 by avibootz
0 votes
using System;

class Program
{
    static void Main()
    {
        string str = @"This is a string with ""double-quoted substring1"", and ""double-quoted substring2"" inside.";
        
        Console.WriteLine(str);
    }
}



/*
run:

This is a string with "double-quoted substring1", and "double-quoted substring2" inside.

*/

 



answered May 12, 2025 by avibootz
...