ASP.NET C# Interfaces in Code Explained

 
Written by Mark Pringle |
Published on:

An interface in C# code is a language construct similar to a class in terms of syntax but fundamentally different. It lists the properties and methods that any class implementing this interface must also implement. Its goal is to build loosely coupled applications whose components are not tightly related or dependent on each other. This minimizes the impact of changing one of the components on other components.

An interface is simply a declaration. It is not a concrete class. It does not have code, cannot have a method body, and cannot be instantiated. It defines a contract that all classes inheriting from it should follow. It declares what a class should have, and the class it inherits from should determine how the interface should use it.

In C# you use the interface keyword, and in ASP.NET, all keywords start with a capital “I.”

Public interface IScientificCaclulator
{
Int Calculator();
}

Interfaces do not have an implementation like classes. Interface members do not have access modifiers like public, private, protected, etc. The Interface method itself is public and abstract by default.

Copyright © TravelDailyLife.com

Author: Mark Pringle
I'm just a guy who is addicted to the unfamiliar and who fulfills this addiction by traveling and writing about my travels. As a lover of sports, penning opinion articles related to sports is also a pastime.
My External Website (External Website Opens in New Window)

Comments

Please Login to Comment
No comments have been posted. Be the first.



Hire a Writer