Efficiency!

Invisionsoft

Well-known member
Joined
Apr 20, 2007
Messages
64
Location
United Kingdom
Programming Experience
1-3
Which do you think is more efficient or better practice for seeing if a string is empty? I wonder about this for all languages. Turns out the 2nd one is the case for PHP.

VB.NET:
if (x.length = 0) Then

OR

VB.NET:
if (x = "") Then


- James
 
The first is faster, especially if the string is not empty, but this is more readable:
If x = String.Empty Then
 
Back
Top