Multiline string literal in C#

后端 未结 13 1939
梦谈多话
梦谈多话 2020-11-22 11:15

Is there an easy way to create a multiline string literal in C#?

Here\'s what I have now:

string query = \"SELECT foo, bar\"
+ \" FROM table\"
+ \" W         


        
13条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 11:27

    One other gotcha to watch for is the use of string literals in string.Format. In that case you need to escape curly braces/brackets '{' and '}'.

    // this would give a format exception
    string.Format(@"", aMagicValue)
    // this contrived example would work
    string.Format(@"", aMagicValue)
    

提交回复
热议问题