如何让c#写引号?
How Do I Get c# to write quotation marks?
我想用c#写一段HPKP代码到文本框里
一段apache HKPK代码长什么样:
Header always set Public-Key-Pins "pin-sha256=\"base64+primary==\"; pin-sha256=\"base64+backup==\"; max-age=5184000; includeSubDomains"
我在 C# 中尝试做的事情:
apacheTextBox.Text = ("Header always set Public-Key-Pins ") + ("pin-sha256=\"base64+primary==\"; pin-sha256=\"base64+backup==\"; max-age=5184000; includeSubDomains");
这导致(输入到文本框中但在此处显示代码以便清晰查看):
Header always set Public-Key-Pins pin-sha256="base64+primary=="; pin-sha256="base64+backup=="; max-age=5184000; includeSubDomains
如您所见,之间缺少两个引号:
pin-sha256="base64+primary=="; pin-sha256="base64+backup=="; max-age=5184000; includeSubDomains
那么如何让c#写引号呢?
\" 将转义 C# 中的引号,以便将引号打印为字符。试试这个
apacheTextBox.Text = ("Header always set Public-Key-Pins ") + ("\"pin-sha256=\"base64+primary==\"; pin-sha256=\"base64+backup==\"; max-age=5184000; includeSubDomains\"");
如上所示,使用\"。在写引号"之前需要一个转义字符\。
apacheTextBox.Text = ("\"Header always set Public-Key-Pins ") + ("pin-sha256=\"base64+primary==\"; pin-sha256=\"base64+backup==\"; max-age=5184000; includeSubDomains\"");
此外,如果您需要反斜杠,请使用双反斜杠 \。第一个是转义字符,第二个是反斜杠。
apacheTextBox.Text = ("\"Header always set Public-Key-Pins ") + ("pin-sha256=\\"base64+primary==\\"; pin-sha256=\\"base64+backup==\\"; max-age=5184000; includeSubDomains\\"");
这里的关键是理解转义字符反斜杠。
我想用c#写一段HPKP代码到文本框里
一段apache HKPK代码长什么样:
Header always set Public-Key-Pins "pin-sha256=\"base64+primary==\"; pin-sha256=\"base64+backup==\"; max-age=5184000; includeSubDomains"
我在 C# 中尝试做的事情:
apacheTextBox.Text = ("Header always set Public-Key-Pins ") + ("pin-sha256=\"base64+primary==\"; pin-sha256=\"base64+backup==\"; max-age=5184000; includeSubDomains");
这导致(输入到文本框中但在此处显示代码以便清晰查看):
Header always set Public-Key-Pins pin-sha256="base64+primary=="; pin-sha256="base64+backup=="; max-age=5184000; includeSubDomains
如您所见,之间缺少两个引号:
pin-sha256="base64+primary=="; pin-sha256="base64+backup=="; max-age=5184000; includeSubDomains
那么如何让c#写引号呢?
\" 将转义 C# 中的引号,以便将引号打印为字符。试试这个
apacheTextBox.Text = ("Header always set Public-Key-Pins ") + ("\"pin-sha256=\"base64+primary==\"; pin-sha256=\"base64+backup==\"; max-age=5184000; includeSubDomains\"");
如上所示,使用\"。在写引号"之前需要一个转义字符\。
apacheTextBox.Text = ("\"Header always set Public-Key-Pins ") + ("pin-sha256=\"base64+primary==\"; pin-sha256=\"base64+backup==\"; max-age=5184000; includeSubDomains\"");
此外,如果您需要反斜杠,请使用双反斜杠 \。第一个是转义字符,第二个是反斜杠。
apacheTextBox.Text = ("\"Header always set Public-Key-Pins ") + ("pin-sha256=\\"base64+primary==\\"; pin-sha256=\\"base64+backup==\\"; max-age=5184000; includeSubDomains\\"");
这里的关键是理解转义字符反斜杠。