3 ms·
When C# was first conceived, it was to be the system language of the .NET platform. It had to, through a pit of success, produce APIs which could be consumed by
by snprbob86 17y ago
When C# was first conceived, it was to be the system language of the .NET platform. It had to, through a pit of success, produce APIs which could be consumed by any CLS compliant language (any language which compiles to MSIL and has a some minimum feature set). Microsoft expected (perhaps naively) developers to use VB.net for application development. Over time, C# has become the primary language choice of the .NET ecosystem. With that change, C# started adding a significant number of non-CLS compliant features.
As a static and strongly typed language, overloading is a very clean solution for implementing default arguments. Haskell, for example, uses the same mechanism. VB, on the other hand, can use late binding. This is an essential feature of VB for COM interop.
Optional and named parameters are being added to C# with support for the "dynamic" type and interop with COM (primarily Office), IronRuby, IronPython, and the HTML DOM via Silverlight. If C# were to stand on its own, I don't think they would have ever added this feature.
EDIT: Also, the actual title of this post is "Two New Features of C# 4.0". Please don't editorialize the headline :-)
- RyanMcGreal 17y agoPlease don't editorialize the headline Mea culpa. :)
- snprbob86 17y agoNo worries. The original title was pretty non-descriptive. I'd have gone with: "Two New Features of C# 4.0 (optional and named parameters)"