An interface is a list of methods, properties, events and indexers that a class may implement. The declaration of an interface looks similar to a class declaration, but doesn’t contain an implementation for any of its members.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| public interface ICowHerd{ // Properties string HerdName { get; set; } string HerdMotto { get; set; } List<CowInfo> Cows { get; set; } // Methods void DisplayHerdInfo(); void DisplayCowInfo(int cowIndex); // Events event EventHandler<CowAddedEventArgs> CowAdded;} |
You can’t do anything with an interface by itself. You can’t instantiate it like a class. Instead, a class can choose toimplement an interface, which means that it will define an implementation for every member of the interface. You can think of the interface as a contract that dictates the exact members that a class must implement if it decides to implement the interface.

