All,
In VB .net I usually test a True or False scenario as below:
' dict is a dictionary
If dict.ContainsKey(anID) = False Then
' Do something
End If
I know that this test could also be written as such:
' dict is a dictionary
If not dict.ContainsKey(anID) Then
' Do something
End If
I have often wondered if one approach is faster than the other? I've had a search of the Internet but failed to find any comparison of the two approaches. I tend to use the first example as I think its easier to read but if anyone has evidence that the second approach is faster I would be interested in hearing. Typically these are embedded in loops that may iterate thousands of times so I think I would put performance over legibility in this case.