I am trying to write a code generator using a c# console application. Now when I type this, I receive an error:
Console.WriteLine("sphere {{0}{1} {2} texture{Gold_Metal}}",
pre, i.ToString(), sprad.ToString());
It says “input in wrong format” I have checked that all the variables were strings, and they are. When I tried
Console.WriteLine("sphere {0}{1} {2} textureGold_Metal",
pre, i.ToString(), sprad.ToString());
It worked perfectly fine. Is there a way to fix this?
Assuming you want a literal
{inserted into the stream, you need to escape a your{with yet another brace thus:Similarly for the end-brace, this is detailed in the MSDN string formatting FAQ here. The sequence
{{becomes{and}}becomes}.From what I understand your intent to be, the full statement in your specific case would be:
which should give you something like: