string.Format() giving “Input string is not in correct format”

string.Format() considers each ‘{‘ or ‘}’ to be part of a placeholder (like ‘{0}’ you already use). You need to escape each literal occurrence by doubling it.

So in your case do:

 string tmp = @"
    if (UseImageFiles) {{
        ...
    }}";

Leave a Comment