Before using String.Format to format a string in C#, I would like to know how many parameters does that string accept?
For eg. if the string was \"{0} is not the same
You'll have to parse through the string and find the highest integer value between the {}
's...then add one.
...or count the number of sets of {}
's.
Either way, it's ugly. I'd be interested to know why you need to be able to figure out this number programatically.
EDIT
As 280Z28 mentioned, you'll have to account for the various idiosyncrasies of what can be included between the {}
's (multiple {}
's, formatting strings, etc.).