Click here to Skip to main content
15,890,557 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: New graduates Pin
Marco Bertschi9-Oct-15 2:15
protectorMarco Bertschi9-Oct-15 2:15 
GeneralRe: New graduates Pin
Brisingr Aerowing9-Oct-15 9:36
professionalBrisingr Aerowing9-Oct-15 9:36 
GeneralRe: New graduates Pin
harold aptroot8-Oct-15 23:09
harold aptroot8-Oct-15 23:09 
GeneralRe: New graduates Pin
BillWoodruff8-Oct-15 23:42
professionalBillWoodruff8-Oct-15 23:42 
GeneralRe: New graduates Pin
F-ES Sitecore9-Oct-15 0:09
professionalF-ES Sitecore9-Oct-15 0:09 
GeneralRe: New graduates Pin
PIEBALDconsult9-Oct-15 5:05
mvePIEBALDconsult9-Oct-15 5:05 
General.net/Java StringBuilder question Pin
Eytukan8-Oct-15 19:44
Eytukan8-Oct-15 19:44 
AnswerRe: .net/Java StringBuilder question Pin
Super Lloyd8-Oct-15 20:00
Super Lloyd8-Oct-15 20:00 
string concatenation ain't that bad...
it's when the number of concatenation is random that it's bad (across multiple statement.. worse, with recursion or loop!), multiple temp object are created and buffer values copied again and again.
but a simple
string s = s1 + S2;
is fine!

i.e.
string s = s1 + S2;
is no worse or better than
StringBuild b = new StringBuild();<br />
sb.Append(s1);<br />
sb.Append(s2);<br />
var s = sb.ToString();


but this:
var s = s1 + s2;<br />
s += s3;<br />
s += s4;<br />

is equivalent to
StringBuild b = new StringBuild();<br />
sb.Append(s1);<br />
sb.Append(s2);<br />
var s = sb.ToString();<br />
sb = new StringBuilder();<br />
sb.Append(s);<br />
sb.Append(s3);<br />
s = sb.ToString();<br />
sb = new StringBuilder();<br />
sb.Append(s);<br />
sb.Append(s4);<br />
s = sb.ToString();<br />

which is much obviously worse that
StringBuild b = new StringBuild();<br />
sb.Append(s1);<br />
sb.Append(s2);<br />
sb.Append(s3);<br />
sb.Append(s4);<br />
s = sb.ToString();<br />

and there is no way to optimize that out....
or you have to do like a human, look at the meaning of the code and rewrite it in a different way with same meaning, not sure compilers go that far yet...
particularly when there is extraneous code in between these string concatenations....
All in one Menu-Ribbon Bar
DirectX for WinRT/C# since 2013!
Taking over the world since 1371!


modified 9-Oct-15 2:06am.

GeneralRe: .net/Java StringBuilder question Pin
Manfred Rudolf Bihy8-Oct-15 22:03
professionalManfred Rudolf Bihy8-Oct-15 22:03 
GeneralRe: .net/Java StringBuilder question Pin
Slacker0078-Oct-15 22:16
professionalSlacker0078-Oct-15 22:16 
GeneralRe: .net/Java StringBuilder question Pin
Super Lloyd9-Oct-15 1:20
Super Lloyd9-Oct-15 1:20 
GeneralRe: .net/Java StringBuilder question Pin
Eytukan9-Oct-15 0:19
Eytukan9-Oct-15 0:19 
GeneralRe: .net/Java StringBuilder question Pin
CDP18028-Oct-15 22:09
CDP18028-Oct-15 22:09 
GeneralRe: .net/Java StringBuilder question Pin
Slacker0078-Oct-15 22:15
professionalSlacker0078-Oct-15 22:15 
GeneralRe: .net/Java StringBuilder question Pin
szukuro8-Oct-15 23:02
szukuro8-Oct-15 23:02 
GeneralRe: .net/Java StringBuilder question Pin
Slacker0079-Oct-15 0:17
professionalSlacker0079-Oct-15 0:17 
GeneralRe: .net/Java StringBuilder question Pin
den2k889-Oct-15 0:28
professionalden2k889-Oct-15 0:28 
GeneralRe: .net/Java StringBuilder question Pin
szukuro9-Oct-15 0:59
szukuro9-Oct-15 0:59 
GeneralRe: .net/Java StringBuilder question Pin
BillWoodruff8-Oct-15 23:29
professionalBillWoodruff8-Oct-15 23:29 
GeneralRe: .net/Java StringBuilder question Pin
Slacker0079-Oct-15 0:20
professionalSlacker0079-Oct-15 0:20 
GeneralRe: .net/Java StringBuilder question Pin
BillWoodruff9-Oct-15 1:27
professionalBillWoodruff9-Oct-15 1:27 
GeneralRe: .net/Java StringBuilder question Pin
Eytukan9-Oct-15 2:31
Eytukan9-Oct-15 2:31 
GeneralRe: .net/Java StringBuilder question Pin
Eytukan9-Oct-15 1:33
Eytukan9-Oct-15 1:33 
GeneralRe: .net/Java StringBuilder question Pin
Nemanja Trifunovic9-Oct-15 2:01
Nemanja Trifunovic9-Oct-15 2:01 
GeneralRe: .net/Java StringBuilder question Pin
Eytukan9-Oct-15 2:24
Eytukan9-Oct-15 2:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.