Is Left right ?
Posted
Wed, Jun 2 2004 3:51
by
bill
Yag posted to Paul’s blog, saying that in some situations Left$ can be better than String.Substring. I think he’s been hanging out with those marketing folk.. oops I mean media folk too much. Of course Yag is right, Left is faster is *some* situations. First, for Left to be faster, the Microsoft.VisualBasic.dll must already have been loaded. There’s a good chance it will have been, but not a given. But most importantly, Left(SomeString, n) is faster only when n is 0 or n is >= SomeString.Length. That is, when the result is either String.Empty or the entire original string.
So, IOW, Microsoft.VisualBasic.Left is faster than String.SubString when Left is not actually returning a sub-string ;-)