A (not so serious) C# 5.0 Language Suggestion
Occasionally I run across less then optimal code as part of my day-to-day work, as do most people who deal with legacy code bases. Even if your code is pure as the driven snow, if you’ve ever spent any time looking at the Code Snippet of The Day on the Daily WTF then you’ll have seen this sort of thing before:
for (int i = 0; i < 200; i++)
{
try { someCollection.RemoveAt(42); }
catch { }
}
Yes, it’s the classic Try, Catch, Swallow pattern in action. If there’s a problem in there, we put our hands in the air like we just don’t care.
So today one of my fellow Readify colleagues, Ivan Hamilton, suggested a new keyword be added to C# 5.0 to help all those developers out there who are constantly writing this sort of thing. Behold the OBVLIVIOUS keyword!
for (int i = 0; i < 200; i++)
{
oblivious { someCollection.RemoveAt(42); }
}
Sheer genius! That code exhibits the same behaviour and is now so much more readable!
If you were on the C# team, what syntactic sugar would you add to the language?