How to insert quotation marks into a string in C#

3 Answers

0 votes
using System;

class Program
{
    static void Main() {
        string str = "c# vb.net \"c\" c++ java "; 

        Console.Write(str);
    }
}



 
/*
run:

c# vb.net "c" c++ java 

*/

 



answered Jul 31, 2023 by avibootz
0 votes
using System;

class Program
{
    static void Main() {
        string str = "c# vb.net "  + '\u0022' + "c"  + '\u0022' + " c++ java "; 

        Console.Write(str);
    }
}



 
/*
run:

c# vb.net "c" c++ java 

*/

 



answered Jul 31, 2023 by avibootz
0 votes
using System;

class Program
{
    static void Main() {
        const string quote = "\""; 
        
        string str = "c# vb.net "  + quote + "c"  + quote + " c++ java "; 

        Console.Write(str);
    }
}



 
/*
run:

c# vb.net "c" c++ java 

*/

 



answered Jul 31, 2023 by avibootz

Related questions

3 answers 161 views
1 answer 69 views
1 answer 98 views
1 answer 94 views
...