string.format vs + for string concatenatoin
- by AMissico
Which is better in respect to performance and memory utilization?
// + Operator
oMessage.Subject = "Agreement, # " + sNumber + ", Name: " + sName;
// String.Format
oMessage.Subject = string.Format("Agreement, # {0}, Name: {1}", sNumber, sName);
My preference is memory utilization. The + operator is used throughout the application. String.Format and StringBuilder is rarely use. I want to reduce the amount of memory fragmentation caused by excessive string allocations.