string.Format 具有以下方法签名
string.Format(format, params, .., .. , ..);
我想每次都传递自定义格式
string custFormat = "Hi {0} ... {n} "; // I only care about numbers here, and want avoid {abdb}
string name = "Foo";
string message = ProcessMessage(custFormat, name);
public string ProcessMessage(custFormat, name)
{
return string.Format(custFormat, name);
}
我想在传递给 ProcessMessage 之前验证 custFormat 中的值以避免异常。