RJB,
In addition to Marina's comments.
I too prefer the Select Case over nested Ifs. However, if I need to use an
If, and I am checking a series of related conditions I would use If/ElseIf
instead of nesting the Ifs if at all possible
Dim firstShift As TimeRange
Dim secondShift As TimeRange
Dim thirdShift As TimeRange
Dim clockIn as DateTime
If firstShift.Contains(clockIn) then
' Do something exciting for the first shift
ElseIf secondShift.Contains(clockIn) Then
' Do something exciting for the second shift
ElseIf thirdShift.Contains(clockIn) Then
' Do something exciting for the third shift
Else
' should "never" happen :-)
Throw New ArgumentException("clockIn", clockIn, "Clock is not in any
shifts")
End If
Search this newsgroup for the implementation of TimeRange & why one might
use it.
Hope this helps
Jay
"RJB" <(E-Mail Removed)> wrote in message
news:BD240FF7-A701-4E5B-9796-(E-Mail Removed)...
>
> Can anybody tell me what is the quickest way )most efficient) method of
> performing comparisons in vb.net?
>
> I'm making modifications to an asp.Net / vb.net application developed by
> someone else. The code base is loaded with nested if statements all doing
> string comparisons. The research that I've done so far indicates that
> string.compareordinal is more efficient than string.compare but I haven't
> been able to locate anything regarding the efficiency of select case vs
> either of these compare methods. Essentially I'm looking for a best
> practice
> for string comparisons.
>
> You thoughts are appreciated. Thank you!!
|