April 2018
Intermediate to advanced
292 pages
6h 44m
English
In the previous section, a class was mentioned that could implement one or more interfaces. It means that such a class must implement all methods, properties, events, and indexers, that are specified in all implemented interfaces. You can easily define interfaces in the C# language using the interface keyword.
As an example, let's take a look at the following code:
public interface IDevice
{
string Model { get; set; }
string Number { get; set; }
int Year { get; set; }
void Configure(DeviceConfiguration configuration);
bool Start();
bool Stop();
}
The IDevice interface contains three properties, namely those representing a device model (Model), serial number (Number), and production year (Year). What's more, it has signatures of ...