What is Polymorphism?

Shikhar Arora

Total Post:6


Posted by  Shikhar Arora
 516  View(s)
Rate this:

 Why and When we should use Polymorphism.

  1. Re: What is Polymorphism?

    Polymorphism means same method playing different roles for different requirements at the same time. For example, Father plays a role of son for his father and at the same time he plays the role of father for his son. 

    namespace Polymorphism
        class Program
            public void Bank()// Defining Bank function without any Parameters
                Console.WriteLine("You have successfully opened an account");
      //Defining Bank method with two Parameters
            public void Bank(int Credit, int Deposit)
                int c = Credit;
                int d = Deposit;
                Console.WriteLine("Credit: " + c + " Deposit: " + d);
      //Defining Bank method with return type and single parameter
            public string Bank(string Msg)
                string msg = Msg;
                return msg;
            static void Main(string[] args)
                Program obj = new Program();//Instantiating Program class
      //Calling more than one method named Bank at the same time
                obj.Bank(4500, 2200);
                Console.WriteLine(obj.Bank("Your account has been credited with Rs. 4500"));


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.