The answers you received won't really help you to write good supportable code, because
the idea is wrong from the very beginning. Like some other beginners, you are doing into a read dead end, which haunts many, these days: you tend to work with string representing objects and data, instead of working objects and data itself. This defeats the purpose of not just the OOP, but, in big part, programming itself.
Instead of
if (cmbMode.SelectedValue.ToString() == "Flashing" && cmbColour.SelectedValue.ToString() == "Blue")
it should be something like
enum CmbMode { Flashing, Steady, }
enum SignColor { Red, Blue, }
CmbMode cmbMode =
SignColor color =
bool snow = cmbMode == CmbMode.Flashing && color == SignColor.Red;
Are you getting the idea?
You may say that you get string from UI. Wrong. You should not. Let's assume this is a
ListBox
. Do you know that you can store any object as items, not strings? You may say that you need strings to show them properly in UI. Yes, but not by putting strings as items. Instead, create a wrapper class or structure and override
System.ToString()
to show some value. This is what the UI will actually show.
If you keep doing comparison of string and immediate "if" blocks like you do, forget programming; it's much better to do no programming than to do it the way you do, quite honestly.
—SA