mercredi 12 juillet 2017

C# If Else Exceptions

i have two variables (well basically four => old/current for each one). all of them can be "ABCDXFG" or ":ABCDXFG" and also "hub".

I have an if else statement to return true if Level names do not equal, but I need exceptions for the hub (it's really long even now) plus another 4 levels!!!

if (current.LevelSecond != old.LevelSecond && current.LevelSecond != old.LevelFirst && current.LevelFirst != "HUB" && old.LevelFirst != "HUB" && current.LevelSecond != "HUB" && old.LevelSecond != "HUB")
    return true;

else if (current.LevelFirst == "HUB" || old.LevelFirst == "HUB" || current.LevelSecond == "HUB" || old.LevelSecond == "HUB")
    return false;

this looks and is absolutely disgusting, and since I have zero experience I don't know how to make this as efficient as possible. If I add those 4 levels the length of the statement is gonna quadruple...

Please help! :(

Aucun commentaire:

Enregistrer un commentaire