Interfaces made easy

Suleiman Abdullah
2 min readSep 30, 2024

--

Objective: Interfaces made easy.

An Interface is like container which define a signature of method and property, and when a class or struct Inherit it must implement all method and property.

We can also call Interface as contract, means when inherit you must implement all of its features into the derived class(A class Inherit Interface) or struct.

We define Interface by starting with public modifier and keyword interface.

Note: Interface can not Inherit anything, plus the standard to rename interface we start with capital I follow by name start with capital letter which end with prefix able. This is not mandatory is just Industry standard which like to be used when create interface.

Now lets implement method signature for property, for property signature means we do not implement any logic.

When add signature for method, remember the method does not have a body its only signature.

A class Inherit Interface must Implement all the properties and methods.

Interface allow us to Inherit as many interface us we like.

Note: A class can not Inherit multiple base class ,it only allow Inheritance to do so.

See you into the next one.

--

--

Suleiman Abdullah

Self taught Unity Developer, who is passion about making games ,and he loves Math For Game Development