How can I tell the number of replacements in a formatter string?
Posted
by sdanna
on Stack Overflow
See other posts from Stack Overflow
or by sdanna
Published on 2010-06-16T20:51:37Z
Indexed on
2010/06/16
21:02 UTC
Read the original article
Hit count: 145
Given the following method: (real method has a few more parameters, but the important ones are below...)
public string DoSomething(string formatter, params string[] values)
{
// Do something eventually involving a call to String.Format(formatter, values);
}
Is there a way to tell if my values array has enough objects in it to cover the formatter, so that I can throw an exception if there aren't (short of doing the string.Format; that isn't an option until the end due to some lambda conversions)?
© Stack Overflow or respective owner