Ehsan-org / ASP.NET-FirstProject

1 stars 0 forks source link

Why should we use INTERFACE in ASP.NET Core? #34

Open ehsan-nadernezhad opened 3 weeks ago

ehsan-nadernezhad commented 1 week ago

Answer:

1) To achieve security - hide certain details and only show the important details of an object (interface).

2) C# does not support "multiple inheritance" (a class can only inherit from one base class).

However, it can be achieved with interfaces, because the class can implement multiple interfaces.

Note: To implement multiple interfaces, separate them with a comma (see example below).