Okay, we know that the following two lines are equivalent –
(0 == i)(i == 0)
Also, the first method was encouraged in the past because that would have allowed the compiler to give an error message if you accidentally used ‘=’ instead of ‘==’.
My question is – in today’s generation of pretty slick IDE’s and intelligent compilers, do you still recommend the first method?
In particular, this question popped into my mind when I saw the following code –
if(DialogResult.OK == MessageBox.Show('Message')) ...
In my opinion, I would never recommend the above. Any second opinions?
I prefer the second one, (i == 0), because it feel much more natural when reading it. You ask people, ‘Are you 21 or older?’, not, ‘Is 21 less than or equal to your age?’