Published: Friday 22 September 2023
A C# interface defines a contract. Essentially, it contains the signatures for the properties and methods. It does not have any implementations associated with them.
A class that inherits an interface must include all properties and methods from it. In-addition, the class can state the implementation for them.
Take this code:
public interface ICurrency
{
string? Symbol { get; }
decimal USDConversationRate { get; }
}
public class USDollarsCurrency : ICurrency
{
}
Why wouldn't this complie and how do we go about fixing it?