views:

81

answers:

5

Is there a way to simplify the process of adding an overloaded method in C# using VS2005?

In VB6, I would have just added an Optional parameter the function, but in C# do I have to have to type out a whole new method with this new parameter?

+1  A: 

with c# 2.0 there is only a way with code generation tools. resharper could do this. with c# 4.0 optional parameters are possible too.

Jack
A: 

yes. in c# 4.0 you can use optional parameters, but in c# 2.0 you have to specify them manually.

Sam Holder
A: 

You can do this with .net 4.0:

   1:  public void SendMail(string toAddress, string bodyText, bool ccAdministrator = true, bool isBodyHtml = false)
   2:  {
   3:      // Full implementation here
   4:  }

In earlier version you need to write separate methods.

MUG4N
A: 

C# 4.0 has optional parameters - see the programming guide.

Oded
A: 

Here is direct link to answer on the page which is a possible dupe of this question.

Ismail