Interface
A list of methods a class promises to provide, with no code of its own.
What is Interface?
An interface is a promise: a list of methods a class agrees to provide, with no code of its own. Any class that implements IPayment must have a Pay method, so the checkout can accept cards, PayPal or gift cards the same way.
public interface IPayment
{
void Pay(decimal amount);
}
public class CardPayment : IPayment
{
public void Pay(decimal amount) => Console.WriteLine( quot;Charged {amount:C} to card");
}
Level: Journeyman · More OOP terms at this level
Updated