Written by Mark Pringle | Last Updated on Monday, December 19, 2022

C# Programming General Information

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.