Interface definition
Context: Define an interface using the interface keyword. It can contain methods, properties, events, and indexers.
Syntax
Section titled “Syntax”[access modifier] interface IInterfaceName{ // method signature int DoWork(string input);
// property signature string Name { get; set; }
// event event EventHandler Updated;}Naming Convention
Section titled “Naming Convention”Prefix with I (e.g., IComparable, IDisposable).
Example
Section titled “Example”public interface ILogger{ void Log(string message); bool IsEnabled { get; set; }}Interface Inheritance
Section titled “Interface Inheritance”Interfaces can inherit from other interfaces.
public interface IReadable { string Read(); }public interface IWritable { void Write(string data); }public interface IReadWrite : IReadable, IWritable { }