【问题标题】:How do I escape quotes in a string variable? [duplicate]如何在字符串变量中转义引号? [复制]
【发布时间】:2014-09-28 19:01:06
【问题描述】:

我有这个: 我想把它放在这个:

 string firstTag = "";

所以最后我会得到:string firstTag = ""; 如果我将在 firstTag 上使用断点,我只会看到:

这是我尝试过的:

public static void test(string filename)
        {
            filename = @"c:\temp\scoopstest\scooptest.html";

            int f = 0;
            int startPos = 0;
            string firstTag = "<font color="898A8E">";

但我收到错误:898A8E">"

【问题讨论】:

标签: c# .net winforms


【解决方案1】:

当然你得到了那个错误。您必须转义引号:

"<font color=\"898A8E\">"
             ^       ^

【讨论】:

    【解决方案2】:

    我不完全确定我是否正确回答了这个问题,但是

    string firstTag = "<font color="898A8E">";
    

    如果你不escape the quotation marks看起来有问题:

    string firstTag = "<font color=\"898A8E\">";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-25
      • 2019-10-20
      • 1970-01-01
      • 2012-11-03
      • 2023-02-26
      • 2023-04-02
      相关资源
      最近更新 更多