Overloading methods in C #

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

In VB6 I would just add an Optional parameter, but in C # I would need to introduce a new new method with this new parameter?

+2


a source to share


4 answers


as of c # 2.0 there is only a way with code generation tools. resharper could do it. with additional options C # 4.0 is also possible.



+1


a source


Yes. In C # 4.0 you can use optional parameters, but in C # 2.0 you have to specify them manually.



0


a source


You can do it 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 an earlier version, you need to write separate methods.

0


a source


C # 4.0 has optional parameters - see programming guide .

0


a source







All Articles