LobsterDK LobsterDK

Niner since 2004


  • Anders Hejlsberg - What influenced the development of C#?

    - Sparky


    I agree that C# and the framework were closely tied together during their development and various features of one influenced the other. However, I don’t believe those features of C# as a language are as tightly coupled with the framework features as you mentioned. Those are just the implementation details of C# on the .NET platform. The ‘using’ construct means “free up this resource after this block exits”. From the language perspective it doesn’t matter how it goes about freeing the resource, just that it frees it. Similarly, the ‘lock’ keyword is a generic (relatively) thread synchronization feature. It just so happens that the C# .NET compiler uses a Monitor to achieve that. Same goes for the foreach statement. It’s to iterate over a collection. The fact that the compiler translates that into the whole IEnumerable deal is a platform implementation detail.


    In other words, C# using, lock, and foreach know nothing about IDisposable, Monitor, and IEnumerator any more than the C++ operators new and delete know about the CRT malloc and free functions that will likely get called as a result of those operators.