Difference in String concatenation performance

Posted by Homer on Stack Overflow See other posts from Stack Overflow or by Homer
Published on 2010-04-09T13:53:00Z Indexed on 2010/04/09 14:03 UTC
Read the original article Hit count: 648

Filed under:
|

I know you should use a StringBuilder when concatenating strings but I was just wondering if there is a difference in concatenating string variables and string literals. So, is there a difference in performance in building s1, s2, and s3?

string foo = "foo";
string bar = "bar";

string s1 = "foo" + "bar";
string s2 = foo + "bar";
string s3 = foo + bar;

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET