How to declare member function in C# interface?


To declare member functions in interfaces in C# −

public interface InterfaceName {
   // interface members
   void InterfaceMemberOne();
   double InterfaceMembeTwo();
   void InterfaceMemberThree()
}

public class ClassName: InterfaceName {
   void InterfaceMemberOne() {
      // interface member
   }
}

Above we saw our interface members are −

void InterfaceMemberOne();
double InterfaceMembeTwo();
void InterfaceMemberThree()

We have then used it in the class for implementing interface −

public class ClassName: InterfaceName {
   void InterfaceMemberOne() {
      // interface member
   }
}

Updated on: 20-Jun-2020

142 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements