Reputation: 14145
I've found some example code which have this line
string.Format(CultureInfo.InvariantCulture, "{0};{1:f2};{2:f3};",item, someDecimalField, decimalAgain);
What are these {1:f2};{2:f3}
and where I can found further info.
Thanks
Upvotes: 3
Views: 131
Reputation: 6953
Those are a simple object parameter like {0}, {1}, {2}. But the difference is that {1:f} has a more information that tells: output this parameter like a floating point. For example {1:C} shows the output in the form of Currency.
Upvotes: 0
Reputation: 1038720
Those are standard format strings
.
"F"
is the fixed point format specifier
:
The fixed-point ("F) format specifier converts a number to a string of the form "-ddd.ddd…" where each "d" indicates a digit (0-9). The string starts with a minus sign if the number is negative.
The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the current NumberFormatInfoNumberDecimalDigits property supplies the numeric precision.
Upvotes: 5