- Home
- .NET coding challenges
- Using an interface in C#
Using an interface in C#
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?
Give us your anonymous feedback regarding this page, or any other areas of the website.