|
tech
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
which is best?sb = New StringBuilder
sb.Append(vbNewLine) sb.Append("function init() {") sb.Append(vbNewLine) sb.Append("ModuleMenu = new TRMenu.TRMenu();") sb.Append(vbNewLine) sb.Append("ModuleMenu.Add('Modules',0,'ModuleMenuList');") Or sb = New StringBuilder sb.Append(vbNewLine & "function init() {" & vbNewLine & "MMenu = new Menu.Menu();" & vbNewLine & "ModuleMenu.Add('Modules',0,'ModuleMenuList');") I've been told that the first method of joining a string is definately a better way of programming. Is this correct? To me it seems like more work to for the same result. Jimbo,
I find definitly the first way much nicer, however the compiler optimizes the second way. I hope this helps, Cor Thanks for your reply.
So for instance: s = New StringBuilder s.Append(vbNewLine) s.Append(vbNewLine) s.Append("function init() {") s.Append(vbNewLine) s.Append("MMenu = new Menu.Menu();") s.Append(vbNewLine) s.Append(vbNewLine) s.Append("MMenu.Add('Modules',0,'MMenuList');") If something Then s.Append(vbnewline) s.Append("and add this:") s.Append("then this") End If Runs better like this: s = New StringBuilder s.Append(vbNewLine & "function init() {" & vbNewLine & "MMenu = new Menu.Menu();" & vbNewLine & "ModuleMenu.Add('Modules',0,'ModuleMenuList');") If something Then s.Append(vbnewline & "and add this: then this") The reason I ask is that our .Net programmer had created a program that I'm guessing has way to many ".Appends" when they are not needed. I could probably reduce the amount of code by a few houndred lines. Show quoteHide quote "Cor Ligthert" wrote: > Jimbo, > > I find definitly the first way much nicer, however the compiler optimizes > the second way. > > I hope this helps, > > Cor Jimbo,
The used time is almost the same and in think that the best is in the middle. Just my idea Cor
Show quote
Hide quote
"Jimbo Jim" <Jimbo***@discussions.microsoft.com> wrote in message I wouldn't use a string builder for the second case ( unless you were going news:25BF1A8A-1803-4646-AA6C-09A8DE6AA720@microsoft.com... > sb = New StringBuilder > sb.Append(vbNewLine) > sb.Append("function init() {") > sb.Append(vbNewLine) > sb.Append("ModuleMenu = new TRMenu.TRMenu();") > sb.Append(vbNewLine) > sb.Append("ModuleMenu.Add('Modules',0,'ModuleMenuList');") > > Or > > sb = New StringBuilder > sb.Append(vbNewLine & "function init() {" & vbNewLine & "MMenu = new > Menu.Menu();" & vbNewLine & > "ModuleMenu.Add('Modules',0,'ModuleMenuList');") > > I've been told that the first method of joining a string is definately a > better way of programming. Is this correct? To me it seems like more work > to > for the same result. > to continue to append ). The string builder becomes efficient when append is used repeatadly
How to use .NET framework to toggle the power on a USB-powered dev
saving file from asp.net Import Excel Data into SQL Server with VB.NET ItemDataBound text modification question Several Crystal Reports Doubts GPS Cookies 2.0 Web site Administration Tool Can't open 'Samples and Quick Start Tutorials' property grid control |
|||||||||||||||||||||||