Questions tagged «verbatim-string»


1
如何将逐字字符串与插值一起使用?
在C#6中,有一个新功能:内插字符串。 这些使您可以将表达式直接放入代码中,而不是依赖索引: string s = string.Format("Adding \"{0}\" and {1} to foobar.", x, this.Y()); 成为: string s = $"Adding \"{x}\" and {this.Y()} to foobar."; 但是,我们使用逐字字符串(主要是SQL语句)在多行中有很多字符串,如下所示: string s = string.Format(@"Result... Adding ""{0}"" and {1} to foobar: {2}", x, this.Y(), x.GetLog()); 将它们恢复为常规字符串似乎很麻烦: string s = "Result...\r\n" + $"Adding \"{x}\" and {this.Y()} to foobar:\r\n" …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.