Generic Interface.

Suleiman Abdullah
2 min readOct 4, 2024

--

Objective: Understand Generic Interface.

To Understand this make sure you know what is interface, here an article about interface.

https://medium.com/@suleimanabdullah/interfaces-made-easy-fa0b8d87289a

Generic Interface

Generic interface is the interface which take T bracket ,and allow any class which inherit this interface to define any data type to be used whether to the method which use T type as parameter or property which take T type as parameter.

To understand this create one interface and one class which inherit from that interface.

To make this Interface as Generic we add T bracket after the name of interface.

Note: The T is only the name you can write anything in there, but by default C# use T as Generic type.

Now I will add method signature to and give T as parameter.

Note: A T type don't have to be a parameter can be even a return type of a method. But I will set my method non return type, this just to show you.

The class which inherit this interface must define the data type in the T bracket and also a method which pass T type as parameter must pass T type when inherit this Interface.

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