String.Format() - 重新传递参数但添加更多参数

Luc*_*ano 6 .net c# string-formatting params-keyword

我想做那样的事情:

public string GetMessage(params object otherValues[]) {
    return String.Format(this.Message, this.FirstValue, otherValues);
}
Run Code Online (Sandbox Code Playgroud)

所以,我想修复一系列参数,String.Format()但添加一个新参数.

什么是最好的方法,知道我们可以"重建"一个新的对象数组,这似乎并不好.

Tim*_* S. 17

public string GetMessage(params object[] otherValues)
{
    return String.Format(this.Message, new[] { this.FirstValue }.Concat(otherValues).ToArray<object>());
}
Run Code Online (Sandbox Code Playgroud)