Junior From PDF OOP C# OOP

What is the role of interfaces in achieving polymorphism?

  • Interfaces allow different classes to implement the same contract, enabling

dynamic behavior at runtime.

interface IDriveable { void Drive(); }
class Car : IDriveable { public void Drive() =>

Console.WriteLine("Car drives"); }

class Bike : IDriveable { public void Drive() =>

Console.WriteLine("Bike drives"); }

More from C# Programming Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details