C# > Interfaces

C# > Interfaces


In this section we shall learn about interfaces.

Interfaces:

  • An interface is similar to class but it provides a specification rather than the implementation for its members. An interface is special in the following ways.
  • Interface members are implicitly abstract, In constrast, a class can provide both abstract members concrete members with implementation.
  •  A class can implement multiple interfaces. In contrast, a class can inherit from only a single class and struct can not inherit at all

The declaration of the interfaces

Interfaces are declared using interface keyword. Interface keywords are public by default

interface IExample
{
    void SampleMethod();
}

In the above code snippet we have declared the interface. We have defined the interface as Iexample  and we have defined the interface as voidSamplemethod() .

There  are different types of interfaces they are 

  • Multiple interfaces 
  • Explicit interfaces
  • Virtual interfaces

Read posts under C# > Interfaces

1 posts found
  1. Interfaces



Write for us






Hosting Recommendations