有什麼辦法可以在編譯時檢查格式字符串嗎?格式字符串 - 編譯時檢查
實施例:
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.