I have an issue with String.Format that I need assistance with:
string Placeholder = @"(function({0}, $, undefined) { {1} }( window.{0} = window.{0} || {}, jQuery));";
string output = string.Format(Placeholder, "Value1", "Value2");
The following exception is thorwn at String.Format
‘string.Format(Placeholder, “Value1”, “Value2”)’ threw an exception of type ‘System.FormatException’ string {System.FormatException}
Any idea why?
It’s because of the braces:
{ {1} }and|| {}. Use doubles:string Placeholder = @"(function({0}, $, undefined) {{ {1} }}( window.{0} = window.{0} || {{}}, jQuery));"; string output = string.Format(Placeholder, "Value1", "Value2");http://geekswithblogs.net/jonasb/archive/2007/03/05/108023.aspx