有没有办法在编译时检查格式字符串?
示例:
Console.WriteLine("{0} is a really {1} site", "stackoverflow.com", "cool");//this will run
//这将给出一个例外,因为只提供了一个参数
Console.WriteLine("{0} is a really {1} site", "stackoverflow.com");
Exception:"Index (zero based) must be greater than or equal to zero and less than the size of the argument list."
如果格式字符串格式不正确(即在此处1之后缺少“}”)
Console.WriteLine("{0} is a really {1 site", "stackoverflow.com","cool");
Exception: Input string was not in a correct format.