Programming Discussions

This is a discussion of programming topics in web and desktop development on MrBool site

Overloading occurs when a method has more than one definition in the same scope. It's important to remember two key points from the previous statement: same name and same scope. The method implementations have the same name because they do similar tasks. For instance, if we need to implement a method that gets the student name, there are many ways to do that. We can get the name using an id and we can get the name using a social security number. As mentioned earlier, overriding has to do with parent and child classes. If you are not satisfied with the implementation of a method in the parent class, you can keep the same declaration (signature and return type), but provide a different implementation. For example, a Rectangle class inherits the drawing functionality from a Shape class, but it overrides this functionality in order to be able to draw a rectangle. We have been using overriding all along in our examples. In C#, everything is an object, so when we create a class ( Employee , Fraction…) that does not specifically inherit from another class, it automatically inherits the functionality of an Object. Notice that in our previous examples, we were able to use the ToString() method to print an object as a string. The ToString() method is defined in the Object class. Since the Object class is too general, this method cannot give us anything useful, so we override it.
Mr Bool
Mr Bool is a great learning experience!
Want to learn more..
Mr Bool site covers all the programming subjects you are intereted in