String Interpolation vs StringBuilder.AppendFormat

  • Thread starter Thread starter Gayan19911212
  • Start date Start date
G

Gayan19911212

Guest
I would like to know the best practise behind concatenating strings and make sure memory would be used sufficiently and compute fast.

I have a loop that would bind number of string and Append into a string builder object (Don'b confused with variable names as it is an example)

StringBuilder strObj = new StringBuilder();

foreach (object obj in objArray)
{
strObj.AppendFormat("Value {0}{1} in {2} in {3}.", obj.A, obj.B, obj.C, obj.D).AppendLine();
}

I would like to know above way is better or will there be another way to implement more efficiently? Or could I include interpolation into StringBuilder? because I was suggested to use string interpolation instead

Thanks in advance

Continue reading...
 
Back
Top