Jak sprawdzić poprawność formatu dla metody string.Format

string.Format ma następujący podpis metody

string.Format(format, params, .., .. , ..);

Chcę przekazywać niestandardowy format za każdym razem

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);
}

Chcę sprawdzić poprawność wartości w custFormat przed przekazaniem do ProcessMessage, aby uniknąć wyjątku.

questionAnswers(4)

yourAnswerToTheQuestion