When we step back for a moment from our SOAs and Factories and Polymorphism, we have to admit that at the root of much of our code lie a hell of a lot of simple if/else statements. Like it or not, they're what makes our program logic tick.
All too often, though, our if logic is reversed - rather than checking for a true condition, we check for false:
if (!myDictionary.Contains(key))
{ }
This syntax, while very common, isn't really easy to parse. While I can express my required logic in words as "if my dictionary does not contain key", my syntax reads like the unintuitive "if not my dictionary does contains key" - I tend to think of my C# code in terms of natural languages. Usually English, even though it's not my native tongue.
So in order to bring C# more in line with my way of thought, I thought of having C# accept this sort of syntax:
if (myDictionary.!Contains(key))
{ }
The .! operator is valid only before a boolean member, and inverts the return value, making it equivalent to the code above. Now the code reads the way it should and is just as easy to understand.
How does this sound? Any other supporters for this? Should I file a feature request on Connect?
