在没有反斜杠的情况下转义字符串中的双引号

时间:2016-02-27 00:01:35

标签: visual-studio-2015

我在Visual Studio中用C#编程,我会用SerialPort发送以下字符串:

AT+CWJAP =  "text1"  ,  "text"

我的代码是:

string a = "AT+CWJAP=";
string b = "\"text1\"";
string c = "\"text\"";
string y = "a + b +  ","  +  c";v

但结果是:y = "AT+CWJAP=\"text1\",\"text\"" 我不想发送反斜杠(\)

1 个答案:

答案 0 :(得分:0)

我想你想要这样的东西:

string a = "AT+CWJAP=";
string b = "\"text1\"";
string c = "\"text\"";
string y = string.Format("{0}{1},{2}", a, b, c); 

Y的值为:AT + CWJAP =" text1"," text"