simple String formatting question

  • Thread starter Thread starter RichB
  • Start date Start date
R

RichB

I am attempting to output a trace with details of the db id of a price
using:

Trace.WriteLine("price id(first price): {0}",evnt.Prices[0].Id);

Wher the Id is a string. I expect from this to output

price id(first price): [priceid]

instead I get:
[priceid]: price id(first price):{0}

Can anyone explain what is going wrong here. I have managed to fix this
issue with the following:

Trace.WriteLine(String.Format("price id(first price):
{0}",evnt.Prices[0].Id));

But why does the string format incorrectly in the first instance?

Thanks, Richard
 
I am attempting to output a trace with details of the db id of a price
using:

Trace.WriteLine("price id(first price): {0}",evnt.Prices[0].Id);

That call is to Trace.WriteLine(string, string). The first parameter
is the message to write, and the second parameter is the category
name. It's *not* a formatting call.

Jon
 
Of course!!

Thanks, Richard

Jon Skeet said:
I am attempting to output a trace with details of the db id of a price
using:

Trace.WriteLine("price id(first price): {0}",evnt.Prices[0].Id);

That call is to Trace.WriteLine(string, string). The first parameter
is the message to write, and the second parameter is the category
name. It's *not* a formatting call.

Jon
 
Back
Top