Escape double quotes in a string

后端 未结 6 2216
轮回少年
轮回少年 2020-11-22 10:35

Double quotes can be escaped like this:

string test = @\"He said to me, \"\"Hello World\"\". How are you?\";

But this involves adding chara

6条回答
  •  借酒劲吻你
    2020-11-22 11:30

    Please explain your problem. You say:

    But this involves adding character " to the string.

    What problem is that? You can't type string foo = "Foo"bar"";, because that'll invoke a compile error. As for the adding part, in string size terms that is not true:

    @"""".Length == "\"".Length == 1
    

提交回复
热议问题