7.7 Method overloading


There isn't much difference between method overloading in Java and in C#. You have multiple methods of the same name and return type in the same class.

Like Java

  • You cannot consider two methods with the same name and parameters but with a different return type as method overloading. For example, having

     public  void  DoThis (int j) {} 

    and

     public  int  DoThis (int j) {return 0;} 

    in the same class is illegal.

  • Constructors can be similarly overloaded. Like Java, you can invoke overloaded constructors from another constructor using the this keyword (see section 7.6).



From Java to C#. A Developers Guide
From Java to C#: A Developers Guide
ISBN: 0321136225
EAN: 2147483647
Year: 2003
Pages: 221
Authors: Heng Ngee Mok

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net