Also what is this feature called in C# I can't seem to locate it.
At the C# level: it isn't - because it isn't a C# feature at all; it is simply a library feature - see also string.Format
. This handy utility method locates {0}
, {1}
, {2}
etc and replaces them with the 0th, 1st, 2nd etc arguments. There is more to it that than, obviously (there are more complex formats available - patterns; negative vs positive, etc).
The documentation for Console.WriteLine
is here: http://msdn.microsoft.com/en-us/library/828t9b9h.aspx
which links to "Composite Formatting": http://msdn.microsoft.com/en-us/library/txafckwd.aspx - which is what the BCL team call this, with intro:
The .NET Framework composite formatting feature takes a list of objects and a composite format string as input. A composite format string consists of fixed text intermixed with indexed placeholders, called format items, that correspond to the objects in the list. The formatting operation yields a result string that consists of the original fixed text intermixed with the string representation of the objects in the list.