You can write a simple extension and use a regex:
public static class StringExtensions
{
public static bool HasPlaceholder(this string s)
{
return Regex.IsMatch(s, "{\\d+}");
}
}
This regex works only for the placeholders you specified (containing only a number).
For a full placeholder you would need something like "{\\d+(,-?\\d+)?(:[A-Z]\\d*)?}"
. But this still needs refinement. See "Standard Numeric Format Strings" for a full list of valid symbols.
You can use this extension like this:
string s = "This string contains {0} a placeholder";
if (s.HasPlaceholder())
Console.WriteLine("Contains placeholders");