Showing posts with label inherit. Show all posts
Showing posts with label inherit. Show all posts

Method Overloading from Inherited Class

Friday, May 27, 2011

Method Overloading from Inherited Class

Method overloading is one of the best essence of Object Oriented Programming which made this dish very tasty for Programmers. And this is going to help you for making your overloading concept very clear if you have a confusion about overloading in inheritance.

This is very basic example but hopefully it will going to help you to understand the concept of overloading of a parent class method in child class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Overloading
{
    class One
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Begin Main Method");
            Two t = new Two();
            t.overload();
            t.overload(0);
            Console.WriteLine("End Main Method");
            Console.Read();
        }

        public void overload()
        {
            Console.WriteLine("Method of class One");
        }
    }

    class Two : One
    {
        public void overload(int number)
        {
            Console.WriteLine("Method of class Two");
        }
    }
}

Output will be:

If you found this post helpful or it can be more helpful by adding something else, so your response will be appreciated. Help me to help you.

**************************LINKS******************************

I have created a new better blog:

My Youtube channel:

**************************LINKS******************************