Tuesday, 6 March 2018

How to implement multiple interfaces with same name in c#

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

namespace ImplementMultipleInterfaceWithSameName
{
    public interface IA
    {
        void show();
    }
    public interface IB
    {
        void show();
    }
    class Program : IA,IB
    {
        static void Main(string[] args)
        {
            IA ai = new Program();
            ai.show();

            IB bi = new Program();
            bi.show();

            Console.ReadLine();
        }

        void IA.show()
        {
            Console.WriteLine("IA interface method show.");
        }
        void IB.show()
        {
            Console.WriteLine("IB interface method show.");
        }
    }
}

output:

IA interface method show.
IB interface method show.

No comments:

Post a Comment