public static string Evaluate(string format, params FormatParam[] args)
{
if (format == null)
throw new ArgumentNullException("format");
if (args == null)
throw new ArgumentNullException("args");
// Initialize the stack to use for processing.
LowLevelStack stack = _cachedStack;
if (stack == null)
_cachedStack = stack = new LowLevelStack();
else
stack.Clear();
// "dynamic" and "static" variables are much less often used (the "dynamic" and "static"
// terminology appears to just refer to two different collections rather than to any semantic
// meaning). As such, we'll only initialize them if we really need them.
FormatParam[] dynamicVars = null, staticVars = null;
int pos = 0;
return EvaluateInternal(format, ref pos, args, stack, ref dynamicVars, ref staticVars);
// EvaluateInternal may throw IndexOutOfRangeException and InvalidOperationException
// if the format string is malformed or if it's inconsistent with the parameters provided.
}