Error!
Success!

C#/.NET Little Pitfalls: Default Parameters are Compile-Time Substitut

0
kicks

C#/.NET Little Pitfalls: Default Parameters are Compile-Time Substitut  (Unpublished)

Default parameters have been around forever both in C++ and in VB. When Java was introduced, however, they were eschewed as being a problematic source of potential code-safety issues. Having been bitten by default parameters before in less strongly-typed languages, I can understand this to an extent. But in many ways this forced us to write heavier code (using overloads) where a default parameter would have been easier to maintain. Java seemed to throw out the baby with the bathwater, just in my opinion, instead of letting the developer decide when using default parameters was the most appropriate choice. C# 1.0, having descended from Java and C++ roots, took the Java approach originally of not allowing default parameters. With the advent of C# 4.0 compiler, however, default parameters are now a part of the C# language. They are a great tool for reducing armies of overloads created to get around the lack of default parameters in early C#. That said, they do have a few things to watch out for so you don’t get bit…


Kicked By:
Drop Kicked By: