15
Reply

How can we use the same method of different interface?

AMIT KUMAR

AMIT KUMAR

8y
1.1k
1
Reply

    By explicit type casting of method

    By explicit type casting of method

    By explicit type casting of method

    By explicit type casting of method

    By explicit type casting of method

    By explicit type casting of method

    By explicit type casting of method

    By explicit type casting of method

    By explicit type casting of method

    By explicit type casting of method

    By explicit type casting of method

    By explicit type casting of method

    By explicit type casting

    interface IAnimal{ string Walk();} interface Ihuman{ string Walk();} public class Iimplement: IAnimal,Ihuman { public string IAnimal.Walk(){return "Snaks crawling..."} public string Ihuman.Walk(){return "men walking..."} }

    public interface ITalk {string Shout(); }public class Dog : ITalk {public string Shout(){return "Woof, woof woof woof woof";} } public class Cat : ITalk {public string Shout(){return "Mew Mew Mew";} } public class Parrot : ITalk {public string Shout(){return "Sqwark! Sqwark! Sqwark!";} } public class Program {static void Main(string[] args){// Writes Woof, WoofITalk pet = new Dog();Console.WriteLine(pet .Speak()); // Now writes MeowITalk pet = new Cat();Console.WriteLine(pet .Speak());// Now writes Sqwark etcITalk pet = new Parrot();Console.WriteLine(pet .Speak());} }