I have a condition like this one:
if (string.IsNullOrEmpty(filename) || size != "Large" || size != "Medium" || size != "Small")
Probability in future I will have to manage more size
in the if
statement.
I would like to know if exist a more manageable and readable way to write this condition.
Please provide a real example thanks for your time on this.
You can keep a hashset of words and check:
HashSet<string> filterWords = new HashSet<string>();
// Put all words in the hash set
if (filterWords.contains(size))
{
// Do what ever you need
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With