Why is there no string.Format Extension Method?
Why is there no built-in extension method like this?
public static string FormatOutput(this string format, params object[] args)
{
return string.Format(format, args);
}
Now the following code
var output = string.Format("This guy's name is {0}", person.Name);
becomes this
var output = "This guy's name is {0}".FormatOutput(person.Name);
Which is much neater in my opinion. Unfortunately we can’t name it ‘Format’ since the compiler gets confused between our extension method and the static method on the string class.