I have a string in which I need to replace markers with values from a dictionary. It has to be as efficient as possible. Doing a loop with a string.replace is just going to
Would stringbuilder.replace be any better [than String.Replace]
Yes, a lot better. And if you can estimate an upper bound for the new string (it looks like you can) then it will probably be fast enough.
When you create it like:
var sb = new StringBuilder(inputString, pessimisticEstimate);
then the StringBuilder will not have to re-allocate its buffer.