C# Tips : Optional and Named Parameters in C#

  • Thread starter Thread starter Jayesh Sorathia
  • Start date Start date
Jayesh Sorathia said:
.Net 4.0 Framework provide Optional and Named Parameters in C# also.
Previously it was supported in VB.Net.
Now you do not need to write unnecessary overload methods , With the help
of the Optional method you can achieve this.

The use of optional (and named) parameters, does not make overloaded methods
unnecessary - but it does make some overloaded methods unnecessary which is
what I'm sure you meant. It is just an alternative. In some situations using
overloaded methods will yield code which is clearer and cleaner than you
would get using optional parameters - in others optional parameters will
give you clearer and cleaner code. So use whichever is the most appropriate
in the situation.
 
The use of optional (and named) parameters, does not make overloaded methods
unnecessary - but it does make some overloaded methods unnecessary which is
what I'm sure you meant. It is just an alternative. In some situations using
overloaded methods will yield code which is clearer and cleaner than you
would get using optional parameters - in others optional parameters will
give you clearer and cleaner code. So use whichever is the most appropriate
in the situation.

Yes Brian , You are right.
I mean in some situations this will remove overloaded methods.
 
Back
Top