[WEBINAR] Application Acceleration: Faster Performance for End Users


Definition - What does Interface mean?

Interface, in C#, is a code structure that defines a contract between an object and its user. It contains a collection of semantically similar properties and methods that can be implemented by a class or a struct that adheres to the contract.

In general, an interface is used to describe a set of related functionalities that can be implemented in a class or struct. It enables a class to inherit multiple behaviors defined in multiple interfaces. It also helps to resolve the name ambiguity that arises while using multiple methods with same names existing in different interfaces.

Designing applications using interfaces helps to address the vital requirements of flexible systems such as loose coupling, separation of concerns and adaptability to future changes. Due to the isolation of components that implement the interfaces of an application, testing these components becomes easier. The .NET Framework library uses many generic interfaces (whose types are parameterized) in collection classes to represent items in a collection so that the boxing and unboxing operations on value types are avoided.

Techopedia explains Interface

An interface is a construct using the keyword "interface" and is similar to an abstract class but without any implementation code. It is implemented using a colon (:) in C#.

For example, IDisposabe is an interface that can be implemented by a C# class to clean up the resources used by the objects of that class type.

The key features of an interface include:
  • It can be declared within a name space or a class.
  • Its members can be a method, property, event or indexer, but cannot be a constant, field, operator, instance constructor, destructor, type or static member.
  • It cannot be instantiated as an object and cannot be defined with data members.
  • Unlike a class that can inherit only one base class and multiple interfaces, an interface can inherit multiple interfaces only.
  • An interface member has public access by default, which cannot be modified using any access modifiers.
  • Modifiers, such as virtual, override or static, should not be used with an interface member.
  • An interface can be accessed using its fully qualified name, which includes the interface name followed by a dot and the member name.
  • An interface member with the "new" modifier can be used to hide an inherited member with the same name.
This definition was written in the context of C#

Techopedia Deals

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
"Techopedia" on Twitter

Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Free Whitepaper: The Path to Hybrid Cloud
Free Whitepaper: The Path to Hybrid Cloud:
The Path to Hybrid Cloud: Intelligent Bursting To Amazon Web Services & Microsoft Azure
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.