Friday, 1 September 2017

C# program example to demonstrate to use of Polymorphism

C# program example to use of Polymorphism in C# program

Program

using System;    
class Program
    {
        static void Main(string[] args)
        {
             add(10);
             add(10, 20);
        }
        public static void add(int x, int y)
        {
            int z = x + y;
            Console.WriteLine("Output1:{0}", z);
        }
        public static void add(int x)
        {
            int y = x + x;
            Console.WriteLine("Output2:{0}", y);
        }

Output


0 comments:

Post a Comment