.NET The most efficient way to replace placeholder text with actual values?

I have a template text (newsletter text) that will be sent to many users; there are some placeholders in the text, such as {{firstname}}, {{lastname}}, etc.

What would be more efficient for replacing placeholders with actual values, .Replace(..)or RegExpor other methods?

.NET language.

+6
source share
2 answers

Since you will name .Replace()several times, it is probably more efficient to use StringBuilder.Replace(), as it is StringBuilder optimized for several modifications .

, , DotLiquid . , , , .

+3

  1. string.Replace.Replace.Replace - , , StringBuilder

  2. StringBuilder.Replace.Replace.Replace 2 , string.Replace,

  3. string.Format("{0},{1},{2}", x, y, z) 20% , StringBuilder, 2x+ , string.Replace.Replace.Replace

+1

All Articles