string template = @"
{
argument1 = ""{0}"";
argument2 = {1};
}";
When I format it as a usual string with string.Format, naturally i get an exception that the input string was not in correct format. I tried escaping the arguments as it is recommended in msdn documentation, like "{{0}}" and even "{{{0}}}", but i still get the same exception. Any ideas on how to format such a string?
Thanks!
P.S.[edit] my original string is for generating a WCAT scenario file:
string scenarioHeaderTemplate = @"
scenario
{{
name = ""WCAT Scenario"";
warmup = {0};
duration = {1};
cooldown = {2};
default
{
version = HTTP11;
setheader
{
name = ""Connection"";
value = ""keep-alive"";
}
statuscode = 200;
close = ka;
}
}}";
and it throws if i try string.Format(scenarioHeaderTemplate, 10, 10, 10);
The problem is the open and close braces. You need to quote those, or Format will think you're begining a parameter specifier.
string template = @"
{{
argument1 = ""{0}"";
argument2 = {1};
}}";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With