Tuesday, 21 February 2017

method overloading example program in c#

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

namespace ConsoleApplication13
{
    public class a
    {
        public void print(int x, int y)
        {
            Console.WriteLine("x value is"+x);
            Console.WriteLine("Y value is"+y);
        }
        public void print(string name, string add)
        {
            Console.WriteLine("my name is "+name);
            Console.WriteLine("my address is " + add);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            a A = new a();
            A.print(10, 20);
            A.print("ravi", "hyd");
            Console.ReadLine();
        }
    }

}

No comments:

Post a Comment