Why use String.Concat() ?
-
value = String.Concat(value, intValue.ToString(), ".");
logBuilder = String.Concat("some long text",
"some long text. ");String errorMessage = String.Concat("Long text, exception: ", ex.ToString());
Find all "String.Concat", Subfolders, Find Results 1, "Current Project" ... Matching lines: 297 Matching files: 32 Total files searched: 106
-
value = String.Concat(value, intValue.ToString(), ".");
logBuilder = String.Concat("some long text",
"some long text. ");String errorMessage = String.Concat("Long text, exception: ", ex.ToString());
Find all "String.Concat", Subfolders, Find Results 1, "Current Project" ... Matching lines: 297 Matching files: 32 Total files searched: 106
-
And this is the best:
String errorMessage = String.Concat(".... packet is fail, exception: ", ex.ToString());
SomeClass.someMember.Error(String.Concat(errorMessage)); -
And this is the best:
String errorMessage = String.Concat(".... packet is fail, exception: ", ex.ToString());
SomeClass.someMember.Error(String.Concat(errorMessage));I think I have spotted this coder in the wild! http://stackoverflow.com/questions/11032394/substring-not-working-as-expected-if-length-greater-than-length-of-string[^] :laugh:
-
I think I have spotted this coder in the wild! http://stackoverflow.com/questions/11032394/substring-not-working-as-expected-if-length-greater-than-length-of-string[^] :laugh:
That has to be him! :laugh:
public class SysAdmin : Employee
{public override void DoWork(IWorkItem workItem) { if (workItem.User.Type == UserType.NoLearn){ throw new NoIWillNotFixYourComputerException(new Luser(workItem.User)); }else{ base.DoWork(workItem); } }
}
-
value = String.Concat(value, intValue.ToString(), ".");
logBuilder = String.Concat("some long text",
"some long text. ");String errorMessage = String.Concat("Long text, exception: ", ex.ToString());
Find all "String.Concat", Subfolders, Find Results 1, "Current Project" ... Matching lines: 297 Matching files: 32 Total files searched: 106
This is just as bad as my example of String.Format. :doh: :wtf:
No matter where you go, there you are...~?~
-
value = String.Concat(value, intValue.ToString(), ".");
logBuilder = String.Concat("some long text",
"some long text. ");String errorMessage = String.Concat("Long text, exception: ", ex.ToString());
Find all "String.Concat", Subfolders, Find Results 1, "Current Project" ... Matching lines: 297 Matching files: 32 Total files searched: 106
If you've read anything about strings, you must have read that you should use StringBuilder instead. "some text" + "some more" + " text" is expensive. I would guess Concat gives you a performance boost similar to StringBuilder, but limited to strings. I have to admit that appending each value individually in builder is bothersome. I know I wanted to find out how much builder helps, so I built a cpu intensive process with accounting numbers. I mixed fixed text with numbers to a string using + logic. Got the actual coding to work and changed over to StringBuilder. Processing went from 40 minutes to 20 minutes. Then I changed the logic to only use builder when I needed to save the stat strings. Cut down to 7 minutes. Then played with the process order and it went to 4 minutes. Needed to buy my second laptop in 7 years to cut it to 2 minutes. :)