When using string.Format (string, object []), it throws an exception if the string contains more format specifiers ({0}, {1: dd-MM-yyyy}, etc.) than the object []. Length.
I would also like to throw an exception if object []. Length contains more specifications. There seems to be no built-in way to do this, so I am trying to get the number of format specifiers in the input string. A complex bit is what {{something}} or {0: dd-MM-yyyy} is allowed to use.
Does anyone know a simple or even built-in way to get the number of format specifiers in a string? I'm currently trying to create a regex, but maybe there is an easier way?
source
share