.NET provides four very similar versions of String.Format(...)
(excluding the one that takes an IFormatProvider
argument):
Format(String, Object)
Replaces one or more format items in a specified string with the string representation of a specified object.
Format(String, Object, Object)
Replaces the format item in a specified string with the string representations of two specified objects.
Format(String, Object, Object, Object)
Replaces the format items in a specified string with the string representation of three specified objects.
Format(String, Object[])
Replaces the format item in a specified string with the string representation of a corresponding object in a specified array.
Why not have just the one with a (params) object[]
argument? Is there a performance gain for separate methods with a fixed number of parameters (1, 2 and 3)?
Presumably, most calls to string.Format in the real world have 1-3 parameters.