473,395 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

which is better

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
Mar 27 '06 #1
6 945
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

"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.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

Mar 27 '06 #2
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

"rodchar" <ro*****@discussions.microsoft.com> schreef in bericht
news:A5**********************************@microsof t.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

Mar 27 '06 #3
The second one is faster by about 50%.

But this is faster by roughly 68%.
ar = str.Split(" "c)
result = ar(0) & " " & ar(1)


"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.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

Mar 27 '06 #4
"rodchar" <ro*****@discussions.microsoft.com> schrieb:
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)


I suggest to choose the second option because it won't perform a useless
'Split' operation.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 27 '06 #5
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...

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.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
Mar 28 '06 #6
thanks everyone for the great help.
rc

"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

Mar 28 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Amit D.Shinde | last post by:
Hello Experts.. I need some help regarding cookies and session objects and also global.asa file I am creating one cookie when a user logs in on my website. The cookie stores the login name of...
6
by: lastusernameleft | last post by:
i've been researching this issue for a while and can't come to any conclusive answer, mostly it seems to be a preference over syntax, some saying c# is elegant while vb is clunky, or that c# is...
1
by: Markus Rebbert | last post by:
Hi list, i got an postgresql installation on linux (debian) with the htree partitions: 1- system 2- postgresql data files 3- postgresql WAL logs(pg_xferlog) Our standard file system is...
4
by: Ed Davis | last post by:
I'm trying to decide which of the following programming styles is better, as in easier to understand, and thus easier to maintain. Keep in mind that for posting purposes, this is a greatly...
9
by: Robert Lario | last post by:
C# verses VB.Net Which Way to go. I am sure this issues has come up before. Please direct me to any good articles that cover this issue. Ideally some neutral assessment.
22
by: smartwolf agassi via DotNetMonster.com | last post by:
I'm a C# language learner. I want to know which IDE is better for C# programing, Borland C#Builder or VS.net 2003? -- Message posted via http://www.dotnetmonster.com
2
by: monkeydragon | last post by:
Which is better, using ReadFile/WriteFile or use fstream?
33
by: Protoman | last post by:
Which is better for general-purpose programming, C or C++? My friend says C++, but I'm not sure. Please enlighten me. Thanks!!!!!
48
by: meyer | last post by:
Hi everyone, which compiler will Python 2.5 on Windows (Intel) be built with? I notice that Python 2.4 apparently has been built with the VS2003 toolkit compiler, and I read a post from Scott...
20
by: mike3 | last post by:
Hi. (Xposted to both comp.lang.c++ and comp.programming since I've got questions related to both C++ language and general programming) I've got the following C++ code. The first routine runs in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.