Take the 2-minute tour ×

This question already has an answer here:

Why shouldn't we simply use

 string s=product.Name+" has been saved";

instead of:

string s=string.Format("{0} has been saved", product.Name);
share|improve this question

marked as duplicate by Soner Gönül, Freelancer, spender, J..., Claudio Redi May 28 '13 at 10:49


Coz in the first case you missed a space after the product name –  V4Vendetta May 28 '13 at 10:41
I tend to use it because you can put a lot of different data types in there, for example numbers without using .ToString (). It just looks neater IMO –  Andrew May 28 '13 at 10:41
@Andrew: Can you give an example for that? –  Aparan May 28 '13 at 10:43

3 Answers 3

up vote 3 down vote accepted

You could do that, no one say that you cannot. But mainly for readability, the second approach is prefered. It's even more obvious as soon as you concat more than 2 strings, it gets really messy, hard to read and mantain.

share|improve this answer
There is no performance advantage? –  Aparan May 28 '13 at 10:42
@Aparan Nope... –  Soner Gönül May 28 '13 at 10:43
@Aparan go through this once blogs.msdn.com/b/ricom/archive/2004/03/12/… –  Freelancer May 28 '13 at 10:44
@Aparan There actually should be an advantage if you have more than one variable to format. –  toasted_flakes May 28 '13 at 10:45
@Aparan: the performance advantage is very irrelevant for the very most of the cases, readability impact is much more important to pick one or other approach. –  Claudio Redi May 28 '13 at 10:48

One naive reason would be that it helps to prevent exactly the string formatting issue that you've presented in your original (unedited) question i.e.

string s=product.Name+"has been saved";

requires an extra space. The format method aids readability.

share|improve this answer

If you have many strings that you want to add, each + operation create new string.

For adding many strings you can use StringBuilder Class or String.Format

share|improve this answer
