Interview Question

What is an interface?

An interface defines capabilities that implementing types agree to provide.

💡 Concept ✅ Quick Revision 🔷 C#

Answer

An interface declares a contract that classes, structs, or other interfaces can implement. • It can declare instance and static members supported by the language version. • A type can implement multiple interfaces. • An explicit interface implementation is accessible through an interface reference.

💡 C# Example

public interface ILogger { void Log(string message); } public sealed class ConsoleLogger : ILogger { public void Log(string message) => Console.WriteLine(message); }

⚡ Quick Revision

An interface defines capabilities that implementing types agree to provide.