In an application I load strings from configuration of this format stackoverflow.com?questionId={0}
. Obviously they're populated at run-time and used in query strings.
I want to log these strings at startup using a method:
void log(string message, params object[] vars)
{
string s = String.Format(message, vars);
Console.WriteLine(s);
}
However as you would expect String.Format
throws an exception because calling: log(String.Format("Adding new feed '{0}'", "stackoverflow.com?questionId={0}"))
- String.Format
tries to substitute {0}
inside 'log()'.
Is there an easy way I can escape the {
characters so substitution isn't attempted?