|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
which is betterhey all,
is there a difference when saying: myString= Split(_dr.TCADR1, " ")(0) & " " & Split(_dr.TCADR1, " ")(1) -or myArrary = Split(_dr.TCADR1, " ") myString = myArray(0) & " " & myArray(1) thanks, rodchar I'd say that there is a performance hit with the first, since it's doing 2
method calls. You'll hardly notice it though (unless you do it a *lot*) so go with whatever feels best. /claes Show quoteHide quote "rodchar" <rodc***@discussions.microsoft.com> wrote in message news:A5498591-3108-46C9-87A8-35A584013FB3@microsoft.com... > hey all, > > is there a difference when saying: > > myString= Split(_dr.TCADR1, " ")(0) & " " & Split(_dr.TCADR1, " ")(1) > > -or > > myArrary = Split(_dr.TCADR1, " ") > myString = myArray(0) & " " & myArray(1) > > thanks, > rodchar Rodchar,
In my opinion is the second the most optimized. It reads easier. However the slight performance benefit will be as well with the second. You need in the second only one split command to be executed, in the first that is two. Just my thought, Cor Show quoteHide quote "rodchar" <rodc***@discussions.microsoft.com> schreef in bericht news:A5498591-3108-46C9-87A8-35A584013FB3@microsoft.com... > hey all, > > is there a difference when saying: > > myString= Split(_dr.TCADR1, " ")(0) & " " & Split(_dr.TCADR1, " ")(1) > > -or > > myArrary = Split(_dr.TCADR1, " ") > myString = myArray(0) & " " & myArray(1) > > thanks, > rodchar The second one is faster by about 50%.
But this is faster by roughly 68%. ar = str.Split(" "c) result = ar(0) & " " & ar(1) Show quoteHide quote "rodchar" <rodc***@discussions.microsoft.com> wrote in message news:A5498591-3108-46C9-87A8-35A584013FB3@microsoft.com... > hey all, > > is there a difference when saying: > > myString= Split(_dr.TCADR1, " ")(0) & " " & Split(_dr.TCADR1, " ")(1) > > -or > > myArrary = Split(_dr.TCADR1, " ") > myString = myArray(0) & " " & myArray(1) > > thanks, > rodchar "rodchar" <rodc***@discussions.microsoft.com> schrieb: I suggest to choose the second option because it won't perform a useless > is there a difference when saying: > > myString= Split(_dr.TCADR1, " ")(0) & " " & Split(_dr.TCADR1, " ")(1) > > -or > > myArrary = Split(_dr.TCADR1, " ") > myString = myArray(0) & " " & myArray(1) 'Split' operation. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> rodchar,
In addition to the other comments. | is there a difference when saying: To the computer, no there is no real difference. Although you are calling Split twice which may have a minor impact on performance speed & GC pressure. Unless the statement is in a tight loop, I would expect the performance impact & GC pressure to be relatively minor... More importantly: To humans (including yourself in 6 months) there is a huge difference! I would expect most developers would find the second to be more immediately obvious what you are trying to do, in other words the "intent of the code". While the first reading the code one has to stop & think about what's happening... -- Show quoteHide quoteHope this helps Jay [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "rodchar" <rodc***@discussions.microsoft.com> wrote in message news:A5498591-3108-46C9-87A8-35A584013FB3@microsoft.com... | hey all, | | is there a difference when saying: | | myString= Split(_dr.TCADR1, " ")(0) & " " & Split(_dr.TCADR1, " ")(1) | | -or | | myArrary = Split(_dr.TCADR1, " ") | myString = myArray(0) & " " & myArray(1) | | thanks, | rodchar thanks everyone for the great help.
rc Show quoteHide quote "rodchar" wrote: > hey all, > > is there a difference when saying: > > myString= Split(_dr.TCADR1, " ")(0) & " " & Split(_dr.TCADR1, " ")(1) > > -or > > myArrary = Split(_dr.TCADR1, " ") > myString = myArray(0) & " " & myArray(1) > > thanks, > rodchar
Deployment without Framework?
Re: Newbie needs help temporarily pausing loop How to read S.M.A.R.T. attributes in vb ? Domains Can you have more than one column in Combo Box Problem deleting rows from dataset (VS2003, VB) Dot Net Deployment Issue in Win98 help please or any coment please only letters or numbers Adding dates to fields from calendar control |
|||||||||||||||||||||||