static void CheckText(string s) { // should be no bare naked %s int index = s.IndexOf('%'); if (index != -1) { char c = index > s.Length - 2 ? '%' : s[index + 1]; throw new UnknownFormatConversionException(new string(c, 1)); } }