AMIT KUMAR
How can we use the same method of different interface?
By AMIT KUMAR in .NET on Sep 09 2016
  • Mukesh Kumar
    Sep, 2017 5

    By explicit type casting of method

    • 0
  • Mohsin Mukri
    Jun, 2017 27

    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..."} }

    • 0
  • AMIT KUMAR
    Sep, 2016 9

    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());} }

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS