Interfaces
An interface is means of making a contract with a class for services that the interface stipulates.
You cannot create an instance of an interface
A class can implement one or more interfaces
A class can inherit from only a single parent, but a class can implement multiple interfaces
Any class that implements an interface must implement all the members of the interface as they are defined.
An interface should not be changed once it has been deployed in your solution.
| IAccessible | |
| IComparer | compares two objects, used for sorting |
| IComparable | |
| IDTExtensibility2 | |
| IEnumerator | designates a class that iterates over a collection, supports for each loops |
| IEnumerable | designates a class that can be enumerated |
| IEqualityComparer | |
| IStartup |
Collection Interfaces
| IList | |
| IDictionary |
vs Abstract Base Classes
Abstract Base Classes
The key difference between an interface and an abstract base class is very subtle
A MustInherit base class serves as the base class for a family of derived classes while an interface is meant to be mixed in with other inheritance trees (?)
When it implements a Visual Basic class in effect promises to provide the functionality the interface specirfies.
An interface is a contract that guarantees to a client how a class or structure will behave.
When a class implements an interface, it tells the client that they guarantee certain methods, properties, events and indexers of the named interface.
An interface offers an alternative to a MustInherit class for creating contracts amound classes and their clients.
These contracts are made manifest using the Interface keyword which declares a reference type that encapsulates the contract.
Syntactically an interface is like a class that only MustInherit methods.
often used as a way of implementing multiple inheritance
all access modifiers are assumed to be public
Express what is common across classes
Allow classes to share a common design
Allows lose coupling between components
Cannot include any implementation details (or fields)
interface IMyInterface
{
void Draw(); //method
string Name { get; } //property
object this[int n] { get; } //indexer
}
class Instance1 : IMyInterface
{
public void Draw() {----}
public string Name { get { return("one"); } }
object this[int n] { get { return(---); } }
}
class Instance2 : IMyInterface
{
public void Draw() {----}
public string Name { get { return("two"); } }
object this[int n] { get { return(---); } }
}
Partial Interfaces
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopNext