C# is mostly stronglt typed, however, there are a few odd behaviors:
e.g. when rolling your own enumerator class, you do not have to implement IEnumerable, you only have to implement a method called GetEnuerator(), you will still be able to foreach
over it.
Same goes for some of the Linq support, you can write your own Linq provider just by providing some select
where
methods etc.
So why is IDisposable required for the using(x){}
statement?
I do get why the linq provider can be written in such a way since there is no fixed contract to fullfill, only a sort of pattern of methods.
Why was the C# compiler(or language spec?) designed in such a way that interfaces are needed for some of the built in language constructs, but not for others?