**Developer**
| > I normally use "something = "" " or sometimes "something = string.empty"
| > when I need to see if I have an empty string. VB automatically checks
| > something for nothing in addition to being empty (as = calls the
VB.StrCmp
| > routine)
| does all this agree with Adelino's reply(especially the
| "as = calls the VB.StrCmp routine" statement)
Naturally as StrCmp is the function call that checks the arguments for
Nothing... Plus it takes into account your Option Compare setting...
--
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
|
| message | > **Developer**
| > Short answer: No
| >
| > Long Answer: As you've noticed: You will receive an answer for every
| > developer out there. ;-)
| >
| > I only use "somestring.Length = 0" when I need to check the length of a
| > string, rarely do I need to check the length of a string, normally I
need
| > to
| > use the length of a string.
| >
| > I normally use "something = "" " or sometimes "something = string.empty"
| > when I need to see if I have an empty string. VB automatically checks
| > something for nothing in addition to being empty (as = calls the
VB.StrCmp
| > routine)
|
|
| Jay,
| does all this agree with Adelino's reply(especially the
| "as = calls the VB.StrCmp routine" statement)
|
| If not, please comment
|
| As always, Thanks
|
|
|
| >
| > I only use "something Is Nothing" when I explicitly need to know if
there
| > is
| > a string there or not. Normally I use this as guard conditions in
| > constructors & methods to throw ArgumentNullExceptions, Something Like:
| >
| > Public Class Something
| >
| > Private Readonly m_name As String
| >
| > Public Sub New(name As String)
| > If name Is Nothing Then Throw New
ArgumentNullException("name")
| > m_name = name
| > End Sub
| >
| > Public Sub PlayWith(other As String)
| > If other Is Nothing Then Throw New
| > ArgumentNullException("other")
| >
| > ' we can use instance methods on both other & m_name here
| > ' without fear of NullReferenceExceptions...
| > End Sub
| >
| > End Class
| >
| > --
| > Jay [MVP - Outlook]
| > .NET Application Architect, Enthusiast, & Evangelist
| > T.S. Bradley -
http://www.tsbradley.net
| >
| >
| > | > |I understand that
| > |
| > | If somestring.length = 0 Then
| > |
| > | is faster then
| > |
| > | If somestring = "" Then
| > |
| > | and is equivalent to
| > |
| > | If (somestring is Nothing) AndAlso (somestring = "") Then
| > |
| > | Is that correct???
| > |
| > |
| > |
| > | Also is there something better then:
| > |
| > | somestring = ""
| > |
| > |
| > |
| > | Thanks
| > |
| > |
| >
| >
|
|