我有一个MSVC 2012的MCVE:
using System;
namespace ConsoleApplication1
{
internal class Program
{
private static void Main(string [] args)
{
string result = string.Format(@"{{{0:G};{1:G}}}", foo(), bar());
Console.WriteLine(result);
}
private static string foo() { return "foo"; }
private static string bar() { return "bar"; }
}
}
期望输出:{foo;bar}
结果:{foo;bar
将格式字符串更改为@"{{{0:G};{1:G} }}"
(添加一个空格)可以产生正确的输出。这是可能的错误吗?或者为什么转义的闭合花括号没有显示?