Search code examples
wcfweb-servicesservicecontract

Why do WCF services use interfaces as a Service Contract instead of an abstract class?


This is a question I got asked in an interview.

When you create a WCF service, you get two files; "IService.cs" and "Service.cs". Why is it a class implementing an interface versus a class inheriting an abstract class. Don't reply saying that you cannot put a [servicecontract] attribute over the abstract class. I know you can only apply it to interfaces, but why?


Solution

  • One can implement more than one interface. One can only inherit a single abstract class.