Posted
Posted 2/5/2010 5:14:34 PM
Does VB.NET's if-then-else syntax bother the crap out of anyone else out there?
If isCondition AndAlso isOtherCondition Then
DoSomething()
ElseIf isCondition Then
DoSomethingElse()
ElseIf isOtherCondition Then
DoSomethingElseElse()
End If
Wow, that's verbose and wasteful for a simple operation like that, don't ya think? Fortunately, VB.NET still carries over the : operator from the decades of yore, and we can abbreviate it thusly:
If isCondition AndAlso isOtherCondition Then
DoSomething()
ElseIf isCondition Then : DoSomethingElse()
ElseIf isOtherCondition Then : DoSomethingElseElse() : End If
Still needs work. Just for comparison, let's see what this is like in C#:
if (isCondition && isOtherCondition) DoSomething();
else if (isCondition) DoSomethingElse();
else if (isOtherCondition) DoSomethingElseElse();
Aaaaahhhhhh, that's better.
And don't even get me started on the ?? and ?: operators. Come on VB, you need these things!
Project Codename MV8
Copyright © 2010 Kevin Connolly. All rights reserved.
Your request ate 82 of my milliseconds.