I have a combobox that has a list of dates in it. I want to ensure that the user actually selects a date. So, I've got the following:
if (cmbDateSelecter.SelectedItem.ToString().ToLower().Contains("select") ||
cmbDateSelecter.SelectedItem.ToString().ToLower().Contains("seleccione") ||
cmbDateSelecter.SelectedItem == null)
The default item is "Select a date", so I'm checking to see if that's the selected item. This used to work on it's own, and for some reason that I haven't figured out yet, started throwing NullReferenceExceptions. So, I added the null check. However, I'm still getting the exception. But if I do:
if(cmbDateSelecter.SelectedItem == null)
Now, I know I can put the null check first, and everything will be hunky dory. My question is why does it not evaluate all expressions before throwing an exception? And if one of them is true, in the case of my expression(being the null check), why does it still throw an exception?