Niclas,
As the others suggest do not use "performance" to decide which to use, I
generally use which is "appropriate" to use.
For simply If/Else I will use an If statement.
If someThing > someThingElse Then
...
Else
...
End If
If I have a "1 of N" conditions (such as evaluating an Enum field) I will
use a Select Case.
Select Case someThing
Case "A"
...
Case "B"
...
Case "C"
...
Case Else
Throw ... something unexpected happened.
End Select
About the only time I use ElseIf is when I an checking object types.
If TypeOf obj Is ListView Then
ElseIf TypeOf obj Is TreeView Then
ElseIf TypeOf obj Is Button Then
Else
Throw ... something unexpected happened.
End If
Yes, this means I favor (when coding) If/ElseIf over Select True/Case/Case.
However! I do see some value in Select True/Case/Case & would recommend it,
for those that follow it. Other languages I've used support it, however
currently C# & C++...
Of course ElseIf & Select Case should be examined for "Replace Conditional
with Polymorphism" refactoring possibilities:
http://www.refactoring.com/catalog/r...ymorphism.html
NOTE: I do not buy into the "Use Select All The Time" school of thought, I
definately don't do:
Select True
Case someThing > someThingElse
...
Case Else
...
End Select
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"Niclas" <NO****@Notmail.com> wrote in message
news:e5**************@TK2MSFTNGP11.phx.gbl...
| Hi,
|
| Is there any performance differences between using
|
| If->Then->Else->End if
|
| and
|
| Select Case -> case Else -> End Select ?
|
| Understand that select case appears better when evaluating multiple
| values, but would like to understand if one is better than the other for
| example when evaluating 2 possible values or if they are equal
|
| (Sad question, i know...)
|
| Niclas
|
|
|
| *** Sent via Developersdex
http://www.developersdex.com ***