Click here to Skip to main content
15,914,780 members
Home / Discussions / C#
   

C#

 
QuestionRe: string concatenation: several seconds Pin
Luc Pattyn2-Dec-11 4:57
sitebuilderLuc Pattyn2-Dec-11 4:57 
AnswerRe: string concatenation: several seconds Pin
OriginalGriff2-Dec-11 5:56
mveOriginalGriff2-Dec-11 5:56 
AnswerRe: string concatenation: several seconds Pin
BobJanova2-Dec-11 6:15
BobJanova2-Dec-11 6:15 
AnswerRe: string concatenation: several seconds Pin
Rick Bassham2-Dec-11 6:16
Rick Bassham2-Dec-11 6:16 
AnswerRe: string concatenation: several seconds Pin
#realJSOP2-Dec-11 7:10
professional#realJSOP2-Dec-11 7:10 
GeneralRe: string concatenation: several seconds Pin
phil.o2-Dec-11 8:46
professionalphil.o2-Dec-11 8:46 
AnswerRe: string concatenation: several seconds Pin
Eddy Vluggen2-Dec-11 7:27
professionalEddy Vluggen2-Dec-11 7:27 
AnswerRe: string concatenation: several seconds Pin
BillWoodruff2-Dec-11 20:11
professionalBillWoodruff2-Dec-11 20:11 
What's missing in this scenario is information about where the strings you add newlines to are coming from.

If you are reading them in from a file, and they are delimited by newlines, that's one case: in that case you can add them to your StringBuilder as you read the file, a line at a time, taking care of delimiting with newlines right there. If it's a file, but not delimited with newlines, and you've got to parse the whole file to create the whatever semantic units that are to become "lines," that's another story. And, finally, if these strings are being created on-the-fly by you ... being calculated/composed in some way: another scenario.

If you can focus on getting the strings into a List<string>, you can just call 'Sort on that List, and then you can directly fill a TextBox by setting the 'Lines property of that TextBox (an array of string) to, courtesy of Linq, the List<string> converted to an array: as in:
XML
List<string> sl = new List<string> { "wo", "ab", "c"};

sl.Sort();

textBox1.Lines = sl.ToArray();
And all of the above, as is said in almost every answer above, should not obscure that the problem here is probably not in the speed of StringBuilder itself.
"Anyone who shows me my 'blind spots' gives me the gift of sight." ... a thought from the shallows of the deeply shallow mind of ... Bill

QuestionChanging ForeColor Item in ListBox ... Pin
nassimnastaran2-Dec-11 0:41
nassimnastaran2-Dec-11 0:41 
AnswerRe: Changing ForeColor Item in ListBox ... Pin
Dan Mos2-Dec-11 1:03
Dan Mos2-Dec-11 1:03 
AnswerRe: Changing ForeColor Item in ListBox ... Pin
Alan N2-Dec-11 1:49
Alan N2-Dec-11 1:49 
GeneralRe: Changing ForeColor Item in ListBox ... Pin
Dan Mos2-Dec-11 1:55
Dan Mos2-Dec-11 1:55 
GeneralRe: Changing ForeColor Item in ListBox ... Pin
Wonde Tadesse2-Dec-11 17:05
professionalWonde Tadesse2-Dec-11 17:05 
AnswerRe: Changing ForeColor Item in ListBox ... Pin
Luc Pattyn2-Dec-11 4:06
sitebuilderLuc Pattyn2-Dec-11 4:06 
AnswerRe: Changing ForeColor Item in ListBox ... Pin
BobJanova2-Dec-11 5:46
BobJanova2-Dec-11 5:46 
QuestionWhat should be the Return Type? Pin
AmbiguousName1-Dec-11 23:40
AmbiguousName1-Dec-11 23:40 
AnswerRe: What should be the Return Type? Pin
BobJanova1-Dec-11 23:55
BobJanova1-Dec-11 23:55 
GeneralRe: What should be the Return Type? Pin
AmbiguousName2-Dec-11 0:22
AmbiguousName2-Dec-11 0:22 
AnswerRe: What should be the Return Type? Pin
Dan Mos2-Dec-11 0:54
Dan Mos2-Dec-11 0:54 
GeneralRe: What should be the Return Type? Pin
BobJanova2-Dec-11 5:44
BobJanova2-Dec-11 5:44 
AnswerRe: What should be the Return Type? Pin
Rob Philpott2-Dec-11 1:07
Rob Philpott2-Dec-11 1:07 
GeneralRe: What should be the Return Type? Pin
BobJanova2-Dec-11 5:45
BobJanova2-Dec-11 5:45 
GeneralRe: What should be the Return Type? Pin
Rob Philpott2-Dec-11 5:50
Rob Philpott2-Dec-11 5:50 
AnswerRe: What should be the Return Type? Pin
PIEBALDconsult2-Dec-11 2:08
mvePIEBALDconsult2-Dec-11 2:08 
GeneralRe: What should be the Return Type? Pin
Eddy Vluggen2-Dec-11 7:30
professionalEddy Vluggen2-Dec-11 7:30 

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.