How can I do this elegantly with C#?
For example, a number can be between 1 and 100.
I know a simple if (x >= 1 && x <= 100)
would suffice; but with a lot of syntax sugar and new features constantly added to C#/.Net this question is about more idiomatic (one can all it elegance) ways to write that.
Performance is not a concern, but please add performance note to solutions that are not O(1) as people may copy-paste the suggestions.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…