2
Reply

Overloading vs Overriding ?

Legolas

Legolas

13y
7.6k
0
Reply

    In overloading, function signature is different. It occurs in same class.
    In overriding, Function signature is same. It happens in base and derived class.

    There are two types of overloading(method and operator)
    Method overloading
      allows the programmer do define several methods with the same name, as long as they take a different set of parameters.
    When you use the classes of the .NET framework, you will soon realize that method overloading is used all over the place. A good example of this, is the Substring() method of the String class. It is with an extra overload, like this:

    string Substring (int startIndex)
    string Substring (int startIndex, int length)

    You can call it with either one or two parameters. If you only call it with one parameter, the length parameter is assumed to be the rest of the string, saving us time whenever we simply want to get the last part of a string.


    Operator overloading

    http://www.codeproject.com/KB/cs/krdeepak123.aspx

    Overriding

    http://msdn.microsoft.com/en-us/library/ebca9ah3%28v=VS.100%29.aspx

    The override modifier is required to extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event. You cannot override a non-virtual or static method. The overridden base method must be virtual, abstract, or override.