I have naive bayes classifier C# console application that includes some static methods. And, I have a web application. Then, I need to convert my console application to WCF service application to use it with my web application. But, the problem is I cannot implement a static interface member. Why? How can I implement static interface member for service application?
IService1.cs:
public interface IService1
{
[OperationContract]
void classify(string[] param1);
}
Service1.cs:
static void classify(string[] param1)
{
// Some code
}
Error:
'NaiveBayesService.NaiveBayesProgram' does not implement interface member 'NaiveBayesService.IService1.classify(string[])'. 'NaiveBayesService.NaiveBayesProgram.classify(string[])' cannot implement an interface member because it is static.
You can't. Think of what an interface represents: A contract that a given instance of a class contains the methods, properties, indexers, etc, that are defined in the interface.
What would the purpose of implementing an interface on a static class be? You'll never have an instance of a static class.
You can implement your interface on a non-static class within your service and instantiate it as part of starting up the service.